def test_info_with_release_date_more_than_a_month_in_future(self): """The release date is ignored since it is too far in the future.""" today_plus_60_days = int( (datetime.today() + timedelta(days=60)).strftime("%s")) self.assertEqual( "OpenQuake version 0.3.2", version.info((0, 3, 2, today_plus_60_days)))
def main(): arg_parser = set_up_arg_parser() args = arg_parser.parse_args() if args.version: print utils_version.info(__version__) elif args.config_file is not None: from openquake import job from openquake import engine try: if args.log_file is not None: # Capture logging messages to a file. try: _touch_log_file(args.log_file) except IOError as e: raise IOError("Error writing to log file %s: %s" % (args.log_file, e.strerror)) user_name = getpass.getuser() ajob = engine.prepare_job(user_name) _, params, sections = engine.import_job_profile(args.config_file, ajob, user_name, args.force_inputs) engine.run_job( ajob, params, sections, output_type=args.output_type, log_level=args.log_level, force_inputs=args.force_inputs, log_file=args.log_file, ) except job.config.ValidationException as e: print str(e) except IOError as e: print str(e) except Exception as e: raise elif args.list_calculations: list_calculations() elif args.list_outputs is not None: list_outputs(args.list_outputs) elif args.export is not None: output_id, target_dir = args.export output_id = int(output_id) do_export(output_id, target_dir) else: arg_parser.print_usage()
def main(): arg_parser = set_up_arg_parser() args = arg_parser.parse_args() if args.version: print utils_version.info(__version__) elif args.config_file is not None: from openquake import job from openquake import engine try: if args.log_file is not None: # Capture logging messages to a file. try: _touch_log_file(args.log_file) except IOError as e: raise IOError('Error writing to log file %s: %s' % (args.log_file, e.strerror)) user_name = getpass.getuser() ajob = engine.prepare_job(user_name) _, params, sections = engine.import_job_profile( args.config_file, ajob, user_name, args.force_inputs) engine.run_job(ajob, params, sections, output_type=args.output_type, log_level=args.log_level, force_inputs=args.force_inputs, log_file=args.log_file) except job.config.ValidationException as e: print str(e) except IOError as e: print str(e) except Exception as e: raise elif args.list_calculations: list_calculations() elif args.list_outputs is not None: list_outputs(args.list_outputs) elif args.export is not None: output_id, target_dir = args.export output_id = int(output_id) do_export(output_id, target_dir) else: arg_parser.print_usage()
def test_info_with_datum_less_than_minus_one(self): """The version information is malformed (datum less than -1).""" self.assertEqual( "The OpenQuake version is not available.", version.info([2, -1, -1, -2]))
def test_info_with_release_date_more_than_a_month_in_future(self): """The release date is ignored since it is too far in the future.""" today_plus_60_days = int( (datetime.today() + timedelta(days=60)).strftime("%s")) self.assertEqual("OpenQuake version 0.3.2", version.info((0, 3, 2, today_plus_60_days)))
def test_info_with_data_not_integer(self): """The version information is malformed (non-integers).""" self.assertEqual( "The OpenQuake version is not available.", version.info(("2", "-1", "-1", "-1")))
def test_info_with_data_not_a_tuple(self): """The version information is malformed (not in a tuple).""" self.assertEqual( "The OpenQuake version is not available.", version.info([2, -1, -1, -1]))
def test_info_with_all_data_in_place(self): """All the version information is in place.""" self.assertEqual( "OpenQuake version 0.3.2, released 2011-04-08T06:04:11Z", version.info((0, 3, 2, 1302242651)))
def test_info_with_malformed_version_information(self): """The version information is malformed.""" self.assertEqual( "The OpenQuake version is not available.", version.info((-1,)))
def test_info_with_minor_number_only(self): """Only the minor version number is set.""" self.assertEqual( "OpenQuake version 0.2.0", version.info((-1, 2, -1, -1)))
def test_info_with_sprint_number_only(self): """Only the sprint number is set.""" self.assertEqual( "OpenQuake version 0.0.2", version.info((-1, -1, 2, -1)))
def test_info_with_datum_less_than_minus_one(self): """The version information is malformed (datum less than -1).""" self.assertEqual("The OpenQuake version is not available.", version.info([2, -1, -1, -2]))
def test_info_with_minor_number_only(self): """Only the minor version number is set.""" self.assertEqual("OpenQuake version 0.2.0", version.info((-1, 2, -1, -1)))
def test_info_with_data_not_a_tuple(self): """The version information is malformed (not in a tuple).""" self.assertEqual("The OpenQuake version is not available.", version.info([2, -1, -1, -1]))
def test_info_with_data_not_integer(self): """The version information is malformed (non-integers).""" self.assertEqual("The OpenQuake version is not available.", version.info(("2", "-1", "-1", "-1")))
def test_info_with_malformed_version_information(self): """The version information is malformed.""" self.assertEqual("The OpenQuake version is not available.", version.info((-1, )))
def test_info_with_all_data_in_place(self): """All the version information is in place.""" self.assertEqual( "OpenQuake version 0.3.2, released 2011-04-08T08:04:11", version.info((0, 3, 2, 1302242651)))
def test_info_with_sprint_number_only(self): """Only the sprint number is set.""" self.assertEqual("OpenQuake version 0.0.2", version.info((-1, -1, 2, -1)))