Exemple #1
0
def generate_target_documentation(outdir):
    targets_to_generate = [
        'generic_android', 'generic_linux', 'generic_chromeos',
        'generic_local', 'juno_linux', 'juno_android'
    ]

    intro = (
        '\nThis is a list of commonly used targets and their device '
        'parameters, to see a complete for a complete reference please use the'
        ' WA :ref:`list command <list-command>`.\n\n\n')

    pluginloader.clear()
    pluginloader.update(packages=['wa.framework.target.descriptor'])

    target_descriptors = list_target_descriptions(pluginloader)
    outfile = os.path.join(outdir, 'targets.rst')
    with open(outfile, 'w') as wfh:
        wfh.write(underline('Common Targets'))
        wfh.write(intro)
        for td in sorted(target_descriptors, key=lambda t: t.name):
            if td.name not in targets_to_generate:
                continue
            text = underline(td.name, '~')
            if hasattr(td, 'description'):
                desc = strip_inlined_text(td.description or '')
                text += desc
            text += underline('Device Parameters:', '-')
            text += get_params_rst(td.conn_params)
            text += get_params_rst(td.platform_params)
            text += get_params_rst(td.target_params)
            text += get_params_rst(td.assistant_params)
            wfh.write(text)
def generate_target_documentation(outdir):
    targets_to_generate = ['generic_android',
                           'generic_linux',
                           'generic_chromeos',
                           'generic_local',
                           'juno_linux',
                           'juno_android']

    intro = '\nThis is a list of commonly used targets and their device '\
    'parameters, to see a complete for a complete reference please use the '\
    'WA :ref:`list command <list-command>`.\n\n\n'

    pluginloader.clear()
    pluginloader.update(packages=['wa.framework.target.descriptor'])

    target_descriptors = list_target_descriptions(pluginloader)
    outfile = os.path.join(outdir, 'targets.rst')
    with open(outfile, 'w') as wfh:
        wfh.write(underline('Common Targets'))
        wfh.write(intro)
        for td in sorted(target_descriptors, key=lambda t: t.name):
            if td.name not in targets_to_generate:
                continue
            text = underline(td.name, '~')
            if hasattr(td, 'description'):
                desc = strip_inlined_text(td.description or '')
                text += desc
            text += underline('Device Parameters:', '-')
            text += get_params_rst(td.conn_params)
            text += get_params_rst(td.platform_params)
            text += get_params_rst(td.target_params)
            text += get_params_rst(td.assistant_params)
            wfh.write(text)
Exemple #3
0
def get_rst_from_target(target):
    text = underline(target.name, '~')
    if hasattr(target, 'description'):
        desc = strip_inlined_text(target.description or '')
        text += desc
    text += underline('Device Parameters:', '-')
    text += get_params_rst(target.conn_params)
    text += get_params_rst(target.platform_params)
    text += get_params_rst(target.target_params)
    text += get_params_rst(target.assistant_params)
    text += '.. Note: For available runtime parameters please see the documentation'
    return text + '\n'
Exemple #4
0
def get_rst_from_target(target):
    text = underline(target.name, '~')
    if hasattr(target, 'description'):
        desc = strip_inlined_text(target.description or '')
        text += desc
    text += underline('Device Parameters:', '-')
    text += get_params_rst(target.conn_params)
    text += get_params_rst(target.platform_params)
    text += get_params_rst(target.target_params)
    text += get_params_rst(target.assistant_params)
    text += '.. Note: For available runtime parameters please see the documentation'
    return text + '\n'
Exemple #5
0
    def generate_run_detail(self):
        detail = underline('Run Events') if self.ro.events else ''

        for event in self.ro.events:
            detail += '{}\n'.format(event.summary)

        return detail + '\n'
Exemple #6
0
    def generate_run_header(self):
        info = self.ro.info

        header = underline('Run Info')
        header += "UUID: {}\n".format(info.uuid)
        if info.run_name:
            header += "Run name: {}\n".format(info.run_name)
        if info.project:
            header += "Project: {}\n".format(info.project)
        if info.project_stage:
            header += "Project stage: {}\n".format(info.project_stage)

        if info.start_time:
            duration = _seconds_as_smh(self.elapsed_time.total_seconds())
            header += ("Start time: {}\n"
                       "Duration: {:02}:{:02}:{:02}\n"
                       ).format(info.start_time,
                                duration[2], duration[1], duration[0],
                                )
            if self.segmented['finished'] and not info.end_time:
                p_duration = _seconds_as_smh(self.projected_duration.total_seconds())
                header += "Projected time remaining: {:02}:{:02}:{:02}\n".format(
                    p_duration[2], p_duration[1], p_duration[0]
                )

            elif self.ro.info.end_time:
                header += "End time: {}\n".format(info.end_time)

        return header + '\n'
Exemple #7
0
def get_rst_for_envars():
    text = underline('Environment Variables')
    text += '''WA_USER_DIRECTORY: str
    This is the location WA will look for config.yaml, plugins,  dependencies,
    and it will also be used for local caches, etc. If this variable is not set,
    the default location is ``~/.workload_automation`` (this is created when WA
    is installed).

    .. note.. This location must be writable by the user who runs WA.'''
    return text
Exemple #8
0
def get_rst_for_global_config():
    text = underline('Global Configuration')
    text += 'These parameters control the behaviour of WA/run as a whole, they ' \
            'should be set inside a config file (either located in ' \
            '$WA_USER_DIRECTORY/config.yaml or one which is specified with -c), ' \
            'or into config/global section of the agenda.\n\n'

    cfg_points = MetaConfiguration.config_points + RunConfiguration.config_points
    text += get_params_rst(cfg_points)
    return text
Exemple #9
0
def get_rst_for_envars():
    text = underline('Environment Variables')
    text += '''WA_USER_DIRECTORY: str
    This is the location WA will look for config.yaml, plugins,  dependencies,
    and it will also be used for local caches, etc. If this variable is not set,
    the default location is ``~/.workload_automation`` (this is created when WA
    is installed).

    .. note.. This location must be writable by the user who runs WA.'''
    return text
Exemple #10
0
def get_rst_for_global_config():
    text = underline('Global Configuration')
    text += 'These parameters control the behaviour of WA/run as a whole, they ' \
            'should be set inside a config file (either located in ' \
            '$WA_USER_DIRECTORY/config.yaml or one which is specified with -c), ' \
            'or into config/global section of the agenda.\n\n'

    cfg_points = MetaConfiguration.config_points + RunConfiguration.config_points
    text += get_params_rst(cfg_points)
    return text
Exemple #11
0
    def generate_job_detail(self):
        detail = underline('Job Detail')
        for job in self.jobs:
            detail += ('{} ({}) [{}]{}, {}\n').format(
                job.id,
                job.label,
                job.iteration,
                ' - ' + str(job.retries)if job.retries else '',
                self._fmt.highlight_keyword(str(job.status))
            )

            job_output = self.job_outputs[(job.id, job.label, job.iteration)]
            for event in job_output.events:
                detail += self._fmt.fit_term_width(
                    '\t{}\n'.format(event.summary)
                )
        return detail
Exemple #12
0
    def generate_job_summary(self):
        total = len(self.jobs)
        num_fin = len(self.segmented['finished'])

        summary = underline('Job Summary')
        summary += 'Total: {}, Completed: {} ({}%)\n'.format(
            total, num_fin, (num_fin / total) * 100
        ) if total > 0 else 'No jobs created\n'

        ctr = Counter()
        for run_state, jobs in ((k, v) for k, v in self.segmented.items() if v):
            if run_state == 'finished':
                ctr.update([job.status.name.lower() for job in jobs])
            else:
                ctr[run_state] += len(jobs)

        return summary + ', '.join(
            [str(count) + ' ' + self._fmt.highlight_keyword(status) for status, count in ctr.items()]
        ) + '\n\n'
Exemple #13
0
def generate_plugin_documentation(source_dir, outdir, ignore_paths):
    pluginloader.clear()
    pluginloader.update(packages=GENERATE_FOR_PACKAGES)
    if not os.path.exists(outdir):
        os.mkdir(outdir)

    for ext_type in pluginloader.kinds:
        outfile = os.path.join(outdir, '{}s.rst'.format(ext_type))
        with open(outfile, 'w') as wfh:
            wfh.write('.. _{}s:\n\n'.format(ext_type.replace('_', '-')))
            title = ' '.join([capitalize(w) for w in ext_type.split('_')])
            wfh.write(underline('{}s'.format(title)))
            wfh.write(insert_contents_table())
            wfh.write(line_break())
            exts = pluginloader.list_plugins(ext_type)
            sorted_exts = iter(sorted(exts, key=lambda x: x.name))
            try:
                wfh.write(get_rst_from_plugin(sorted_exts.next()))
            except StopIteration:
                return
            for ext in sorted_exts:
                wfh.write(line_break())
                wfh.write(get_rst_from_plugin(ext))