help='DB pass', type=str, required=False) parser.add_argument('-t', '--dbhost', default='', help='DB host', type=str, required=False) parser.add_argument('-r', '--dbport', default='', help='DB port', type=str, required=False) parser.add_argument('-c', '--cores', default=1, help='Number of cores to use [default 1]', type=int, required=False) return parser if __name__ == '__main__': try: utils.checkSuperUser() run(utils.apply_argument_parser(argument_parser())) except Exception as e: print e
# measure elapsed time elapsed_time = time.time() - t0 msg = 'Finished. Total elapsed time: %.02f seconds. See %s' % (elapsed_time, logname) print(msg) logger.info(msg) def argument_parser(): description = "Removes a list of Raw data items and their related converted data from the file structure." parser = argparse.ArgumentParser(description=description) # add required argument group requiredNamed = parser.add_argument_group('required arguments') # arguments requiredNamed.add_argument('-i', '--itemid', help='Comma-separated list of Raw Data Item Ids Raw data item id (with ? the available raw data items are listed)', action='store', required=True) parser.add_argument('-d','--dbname',default=utils.DEFAULT_DB, help='PostgreSQL DB name ' + utils.DEFAULT_DB + ']',type=str , required=False) parser.add_argument('-u','--dbuser',default=utils.USERNAME,help='DB user [default ' + utils.USERNAME + ']',type=str, required=False) parser.add_argument('-p','--dbpass',default='',help='DB pass',type=str, required=False) parser.add_argument('-t','--dbhost',default='',help='DB host',type=str, required=False) parser.add_argument('-r','--dbport',default='',help='DB port',type=str, required=False) parser.add_argument('-l', '--log', help='Log level', choices=utils.LOG_LEVELS_LIST, default=utils.DEFAULT_LOG_LEVEL) return parser if __name__ == '__main__': try: utils.checkSuperUser() run(utils.apply_argument_parser(argument_parser())) except Exception as e: print e