def initialize(self): section = 'job.run.result.xunit' help_msg = ('Enable xUnit result format and write it to FILE. ' 'Use "-" to redirect to the standard output.') settings.register_option(section=section, key='output', help_msg=help_msg, default=None) help_msg = ('Enables default xUnit result in the job results ' 'directory. File will be named "results.xml".') settings.register_option(section=section, key='enabled', key_type=bool, default=True, help_msg=help_msg) help_msg = ('Override the reported job name. By default uses the ' 'Avocado job name which is always unique. This is useful ' 'for reporting in Jenkins as it only evaluates ' 'first-failure from jobs of the same name.') settings.register_option(section=section, key='job_name', default=None, help_msg=help_msg) help_msg = ('Limit the attached job log to given number of characters ' '(k/m/g suffix allowed)') settings.register_option(section=section, key='max_test_log_chars', help_msg=help_msg, key_type=lambda x: DataSize(x).b, default=DataSize('100000').b)
def handle_purge(self, config): days = config.get('assets.purge.days') size_filter = config.get('assets.purge.size_filter') overall_limit = config.get('assets.purge.overall_limit') if self._count_filter_args(config) != 1: msg = ("You should choose --by-size-filter or --by-days. " "For help, run: avocado assets purge --help") LOG_UI.error(msg) return exit_codes.AVOCADO_FAIL cache_dirs = config.get('datadir.paths.cache_dirs') try: if days is not None: Asset.remove_assets_by_unused_for_days(days, cache_dirs) elif size_filter is not None: Asset.remove_assets_by_size(size_filter, cache_dirs) elif overall_limit is not None: try: size = DataSize(overall_limit).b Asset.remove_assets_by_overall_limit(size, cache_dirs) except InvalidDataSize: error_msg = "You are using an invalid suffix. " error_msg += "Use one of the following values: " error_msg += ",".join(DataSize.MULTIPLIERS.keys()) LOG_UI.error(error_msg) return exit_codes.AVOCADO_FAIL except (FileNotFoundError, OSError) as e: LOG_UI.error("Could not remove asset: %s", e) return exit_codes.AVOCADO_FAIL return exit_codes.AVOCADO_ALL_OK
def initialize(self): section = "job.run.result.xunit" help_msg = ("Enable xUnit result format and write it to FILE. " 'Use "-" to redirect to the standard output.') settings.register_option(section=section, key="output", help_msg=help_msg, default=None) help_msg = ("Enables default xUnit result in the job results " 'directory. File will be named "results.xml".') settings.register_option( section=section, key="enabled", key_type=bool, default=True, help_msg=help_msg, ) help_msg = ("Override the reported job name. By default uses the " "Avocado job name which is always unique. This is useful " "for reporting in Jenkins as it only evaluates " "first-failure from jobs of the same name.") settings.register_option(section=section, key="job_name", default=None, help_msg=help_msg) help_msg = ("Limit the attached job log to given number of characters " "(k/m/g suffix allowed)") settings.register_option( section=section, key="max_test_log_chars", help_msg=help_msg, key_type=lambda x: DataSize(x).b, default=DataSize("100000").b, )
def configure(self, parser): run_subcommand_parser = parser.subcommands.choices.get('run', None) if run_subcommand_parser is None: return help_msg = ('Enable xUnit result format and write it to FILE. ' 'Use "-" to redirect to the standard output.') settings.register_option(section='run.xunit', key='output', metavar='FILE', action=FileOrStdoutAction, help_msg=help_msg, default=None, parser=run_subcommand_parser.output, long_arg='--xunit') help_msg = ('Enables default xUnit result in the job results ' 'directory. File will be named "results.xml".') settings.register_option(section='run.xunit', key='job_result', help_msg=help_msg, choices=('on', 'off'), default='on', parser=run_subcommand_parser.output, long_arg='--xunit-job-result') help_msg = ('Override the reported job name. By default uses the ' 'Avocado job name which is always unique. This is useful ' 'for reporting in Jenkins as it only evaluates ' 'first-failure from jobs of the same name.') settings.register_option(section='run.xunit', key='job_name', default=None, help_msg=help_msg, parser=run_subcommand_parser.output, long_arg='--xunit-job-name') help_msg = ('Limit the attached job log to given number of characters ' '(k/m/g suffix allowed)') settings.register_option(section='run.xunit', key='max_test_log_chars', metavar='SIZE', help_msg=help_msg, default='100000', key_type=lambda x: DataSize(x).b, parser=run_subcommand_parser.output, long_arg='--xunit-max-test-log-chars')
def __getattr__(self, attr): datasize = DataSize(f"{read_from_meminfo(self.name)}k") return getattr(datasize, attr)
def __getattr__(self, attr): datasize = DataSize('%sk' % read_from_meminfo(self.name)) return getattr(datasize, attr)