diff --git a/scripts/import-from-xon.py b/scripts/import-from-xon.py index 3ad57cb..b19eac3 100644 --- a/scripts/import-from-xon.py +++ b/scripts/import-from-xon.py @@ -7,6 +7,8 @@ from os import listdir, mkdir from os.path import isfile, exists from urllib.parse import unquote +import sys, traceback + #------------------------------------------------+ # get_list_from_server_txt #------------------------------------------------+ @@ -218,17 +220,26 @@ def duplicatestest(d, s): if __name__ == "__main__": ap = argparse.ArgumentParser() - ap.add_argument('db') - ap.add_argument('src') - ap.add_argument('-t', '--test', action='store_true') - ap.add_argument('-q', '--sql', action='store_true') + ap.add_argument('dest', + help="destination, either an sqlite3 database or query file") + ap.add_argument('src', + help="source, should be data generated by a Xonotic server") + ap.add_argument('-t', '--test', + action='store_true', + help="test database for duplicates") + ap.add_argument('-q', '--query', + action='store_true', + help="write query file (as opposed to executing / inserting rows into database)") args = ap.parse_args() log_file = init_logging() print("Writing log to ", log_file) if args.test: duplicatestest(args.db, args.src) - if args.sql: - f(args.db, args.src) + if args.query: + try: + f(args.dest, args.src) + except FileNotFoundError: + traceback.print_exc() + print("\t Exiting - no file to work with.", file=sys.stderr) else: - i(args.db, args.src) - + i(args.dest, args.src)