Example #1
0
def create_html_indexes(args):
    """Create HTML indexes.

    The index.html file will be created within all folders of the `repo_dir`
    element of the *args* dict.

    :param args: Parsed arguments in dictionary format.
    :type args: ``dict``
    """
    full_path = utils.get_abs_path(file_name=args['repo_dir'])
    excludes = [utils.get_abs_path(file_name=i) for i in args['dir_exclude']]

    for fpath, afolders, afiles in os.walk(full_path):
        # Skip excluded directories.
        if [i for i in excludes if fpath.startswith(i)]:
            continue
        else:
            LOG.debug('Path Found: "%s"', fpath)
            _title = 'links for "%s"' % os.path.basename(fpath)
            index = html.HTML('html')
            head = index.head()
            head.title(_title)
            body = index.body(newlines=True)
            body.h1(_title)

            with utils.ChangeDir(fpath):
                LOG.debug('Folders Found: "%d"', len(afolders))
                for afolder in sorted(afolders):
                    full_folder_path = os.path.join(fpath, afolder)
                    body.a(
                        os.path.basename(full_folder_path),
                        href=os.path.relpath(full_folder_path),
                        rel="internal"
                    )
                    body.br()

                LOG.debug('Files Found: "%d"', len(afiles))
                for afile in sorted(afiles):
                    if afile == 'index.html':
                        continue

                    full_file_path = os.path.join(fpath, afile)
                    body.a(
                        os.path.basename(full_file_path).split('#')[0],
                        href=os.path.relpath(full_file_path),
                        rel="internal",
                        md='md5:%s' % return_hash(full_file_path)
                    )
                    body.br()
                else:
                    index_file = os.path.join(fpath, 'index.html')
                    with open(index_file, 'wb') as f:
                        f.write(str(index))
                    LOG.info('Index file [ %s ] created.', index_file)
Example #2
0
def create_report(args, organize_data):
    """Create a package building report.

    :param args: Parsed arguments in dictionary format.
    :type args: ``dict``
    """
    repos = _create_report(args=args, organize_data=organize_data)
    report_file = utils.get_abs_path(file_name=args['report_file'])
    built_report = json.dumps(repos, indent=4, sort_keys=True)
    LOG.info('Built report: %s', built_report)
    with open(report_file, 'w') as f:
        f.write(built_report)
Example #3
0
def create_report(args, organize_data):
    """Create a package building report.

    :param args: Parsed arguments in dictionary format.
    :type args: ``dict``
    """
    repos = _create_report(args=args, organize_data=organize_data)
    report_file = utils.get_abs_path(file_name=args['report_file'])
    built_report = json.dumps(repos, indent=4, sort_keys=True)
    LOG.info('Built report: %s', built_report)
    with open(report_file, 'w') as f:
        f.write(built_report)
Example #4
0
    def _store_pool(self):
        """Create wheels within the storage pool directory."""
        built_wheels = utils.get_file_names(path=self.args['build_output'])

        # Iterate through the built wheels
        for built_wheel in built_wheels:
            _dst_wheel_file_name = os.path.basename(built_wheel)
            # Directory name is being "normalised"
            dst_wheel_file = utils.get_abs_path(
                file_name=os.path.join(
                    self.args['storage_pool'],
                    _dst_wheel_file_name.split('-')[0].lower().replace('_', '-'),
                    _dst_wheel_file_name
                )
            )

            # Create destination file
            if os.path.exists(dst_wheel_file):
                dst_size = os.path.getsize(dst_wheel_file)
                src_size = os.path.getsize(built_wheel)
                if dst_size != src_size:
                    LOG.debug(
                        'Wheel found but the sizes are different. The new'
                        ' wheel file will be copied over. Wheel file [ %s ]',
                        dst_wheel_file
                    )
                    self._copy_file(
                        dst_file=dst_wheel_file,
                        src_file=built_wheel
                    )
            else:
                LOG.debug(
                    'Wheel not found copying wheel into place [ %s ]',
                    dst_wheel_file
                )
                # Ensure the directory exists
                self.shell_cmds.mkdir_p(path=os.path.dirname(dst_wheel_file))
                self._copy_file(
                    dst_file=dst_wheel_file,
                    src_file=built_wheel
                )

            # Create link
            if self.args['link_dir']:
                self._create_link(
                    full_wheel_path=dst_wheel_file,
                    wheel_name=os.path.basename(dst_wheel_file)
                )