def initialize(self, args): load_variants = getattr(args, "json_variants_load", None) if load_variants is None: self.variants = _NO_VARIANTS return try: with open(load_variants, 'r') as var_file: self.variants = varianter.Varianter(state=json.load(var_file)) except IOError: LOG_UI.error( "JSON serialized file '%s' could not be found or " "is not readable", load_variants) if args.subcommand == 'run': sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: sys.exit(exit_codes.AVOCADO_FAIL)
def initialize(self, config): load_variants = config.get('json.variants.load') if load_variants is None: self.variants = _NO_VARIANTS return try: with open(load_variants, 'r', encoding='utf-8') as var_file: self.variants = varianter.Varianter(state=json.load(var_file)) except IOError: LOG_UI.error( "JSON serialized file '%s' could not be found or " "is not readable", load_variants) if config.get('subcommand') == 'run': sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: sys.exit(exit_codes.AVOCADO_FAIL)
def initialize(self, config): # Looks like this could be either 'run' or 'variants' subcommand = config.get('subcommand') load_variants = config.get('{}.json_variants_load'.format(subcommand)) if load_variants is None: self.variants = _NO_VARIANTS return try: with open(load_variants, 'r') as var_file: self.variants = varianter.Varianter(state=json.load(var_file)) except IOError: LOG_UI.error( "JSON serialized file '%s' could not be found or " "is not readable", load_variants) if config.get('subcommand') == 'run': sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: sys.exit(exit_codes.AVOCADO_FAIL)