def run(args): logname = os.path.basename(__file__) + '.log' utils.start_logging(filename=logname, level=args.log) # connect to the DB connection, cursor = utils.connectToDB(args.dbname, args.dbuser, args.dbpass, args.dbhost, args.dbport) itemIds = None if args.itemid != '': itemIds = args.itemid.split(',') utils.listRawDataItems(cursor, itemIds) def argument_parser(): description = "List the Raw data items that are in the DB." parser = argparse.ArgumentParser(description=description) parser.add_argument('-i', '--itemid',default='', help='List the Raw Data Item Ids related to a list of items (comma-separated) [default list all raw data items]', type=str, required=False) 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__': run( utils.apply_argument_parser(argument_parser()))
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