def testPassingWithPickle(self): ''' Use consume_batch.py as a file that should always be there ''' p = cmd.ConsumeParser('pickle') p.do_parse(['app_name_placeholder', 'activity', 'consume_batch.py']) self.assertEqual(p.csv_file, os.path.abspath('consume_batch.py')) self.assertEqual(p.burn_type, 'activity')
def testLoadingsFileDoesntExist(self): p = cmd.ConsumeParser() try: p.do_parse('activity', 'consume_batch.py', '-f', 'non_existent.py') self.assertFalse() except (cmd.ConsumeParserException): pass except: self.assertFalse
def testNonExistentFile(self): p = cmd.ConsumeParser() try: p.do_parse('activity', 'non_existent.py') self.assertFalse() except (cmd.ConsumeParserException): pass except: self.assertFalse
def testBadBurnType(self): p = cmd.ConsumeParser() try: p.do_parse('bogus', 'consume_batch.py') self.assertFalse() except (cmd.ConsumeParserException): pass except: self.assertFalse
def main(): try: can_run() parser = cmdline.ConsumeParser([DO_PICKLE_OUTPUT, DO_RAW_OUTPUT]) parser.do_parse(sys.argv) run(parser.burn_type, parser.csv_file, parser.do_metric, parser.msg_level, parser.output_filename, parser.fuel_loadings_file, parser.col_cfg_file) except Exception as e: print(e)
def testPassingWithMsgLevel(self): ''' Use consume_batch.py as a file that should always be there ''' p = cmd.ConsumeParser() p.do_parse([ 'app_name_placeholder', 'activity', 'consume_batch.py', '-l', '3' ]) self.assertEqual(p.csv_file, os.path.abspath('consume_batch.py')) self.assertEqual(p.burn_type, 'activity') self.assertEqual(p.msg_level, 10) # - logging.DEBUG
def main(): try: can_run() parser = cmdline.ConsumeParser([DO_PICKLE_OUTPUT, DO_RAW_OUTPUT]) parser.do_parse(sys.argv) run(parser.burn_type, parser.csv_file, parser.do_metric, parser.msg_level, parser.output_filename, parser.fuel_loadings_file, parser.col_cfg_file) except Exception as e: tb = sys.exc_info()[2] traceback.print_tb(tb, limit=-5, file=sys.stdout) print(e)
def testPassingWithLoadingsFileAndColCfgFile(self): ''' Use consume_batch.py as a file that should always be there ''' p = cmd.ConsumeParser() p.do_parse([ 'app_name_placeholder', 'activity', 'consume_batch.py', '-f', 'consume_batch.py', '-x', 'consume_batch.py' ]) self.assertEqual(p.burn_type, 'activity') self.assertEqual(p.csv_file, os.path.abspath('consume_batch.py')) self.assertEqual(p.fuel_loadings_file, os.path.abspath('consume_batch.py')) self.assertEqual(p.col_cfg_file, os.path.abspath('consume_batch.py'))
def main(): try: can_run() parser = cmdline.ConsumeParser([DO_PICKLE_OUTPUT, DO_RAW_OUTPUT]) parser.do_parse(sys.argv) if parser.no_sera == True: print("no_sera is True... run without SERA emissions values") run(parser.burn_type, parser.csv_file, parser.do_metric, parser.msg_level, parser.output_filename, parser.fuel_loadings_file, parser.col_cfg_file, parser.no_sera) except Exception as e: tb = sys.exc_info()[2] traceback.print_tb(tb, limit=-5, file=sys.stdout) print(e)