diff --git a/Ccs/tools/import_mib.py b/Ccs/tools/import_mib.py index ba316d907661972ed7c8685611801cb3164eba85..6c985af34b6a2f5357b2673a6a5fa9fb73093e46 100755 --- a/Ccs/tools/import_mib.py +++ b/Ccs/tools/import_mib.py @@ -96,24 +96,39 @@ def import_mib(): s.commit() s.close() - print('...DONE!') - if __name__ == '__main__': + do_import = True + if '-c' in sys.argv: MIBDIR = '/home/user/space/mib' # directory containing the SCOS2000 *.dat files DBNAME = 'mib_schema_test' # SQL schema name to be created DBURL = 'mysql://user:password@127.0.0.1' # credentials of MySQL account - elif len(sys.argv) > 1: + + elif '--dummy' in sys.argv: + sys.argv.remove('--dummy') + DBNAME, dbuser = sys.argv[-2:] + dbpw = getpass.getpass() + DBURL = 'mysql://{}:{}@127.0.0.1'.format(dbuser, dbpw) + do_import = False + + elif len(sys.argv) > 3: MIBDIR, DBNAME, dbuser = sys.argv[1:4] dbpw = getpass.getpass() DBURL = 'mysql://{}:{}@127.0.0.1'.format(dbuser, dbpw) + else: print('USAGE: ./import_mib.py <MIBDIR> <DBSCHEMA> <DBUSERNAME> [-c]\n' - 'Options:\n\t-c\tUse configuration in script, any command line arguments will be ignored') + 'Options:\n\t-c\tUse configuration in script, any command line arguments will be ignored.\n' + '\t--dummy\tCreate empty MIB structure only. Omit <MIBDIR> argument.') + sys.exit() generate_wbsql() create_schema() - import_mib() + + if do_import: + import_mib() + + print('...DONE!')