diff --git a/blitzutils.py b/blitzutils.py index d238819..923f2eb 100644 --- a/blitzutils.py +++ b/blitzutils.py @@ -32,10 +32,7 @@ def setVerbose(verbose: bool): def verbose(msg = ""): """Print a message""" if VERBOSE: - curframe = inspect.currentframe() - calframe = inspect.getouterframes(curframe, 2) - caller = calframe[1][3] - print(caller + '(): ' + msg) + print(msg) return None def debug(msg = ""): @@ -170,20 +167,24 @@ class WG: self.WG_appID = WG_appID self.tanks = None - if tankopedia_fn != None: - try: - with open(tankopedia_fn, 'rt', encoding='utf8') as f: - self.tanks = json.loads(f.read()) - except Exception as err: - error('Could not read tankopedia: ' + tankopedia_fn + '\n' + str(err)) - - if maps_fn != None: - try: - with open(maps_fn, 'rt', encoding='utf8') as f: - self.maps = json.loads(f.read()) - except Exception as err: - error('Could not read maps file: ' + maps_fn + '\n' + str(err)) - + if (tankopedia_fn != None): + if os.path.exists(tankopedia_fn) and os.path.isfile(tankopedia_fn): + try: + with open(tankopedia_fn, 'rt', encoding='utf8') as f: + self.tanks = json.loads(f.read()) + except Exception as err: + error('Could not read tankopedia: ' + tankopedia_fn + '\n' + str(err)) + else: + verbose('Could not find Tankopedia file: ' + tankopedia_fn) + if (maps_fn != None): + if os.path.exists(maps_fn) and os.path.isfile(maps_fn): + try: + with open(maps_fn, 'rt', encoding='utf8') as f: + self.maps = json.loads(f.read()) + except Exception as err: + error('Could not read maps file: ' + maps_fn + '\n' + str(err)) + else: + verbose('Could not find maps file: ' + maps_fn) if self.WG_appID != None: self.session = aiohttp.ClientSession() else: diff --git a/extractTankopedia.py b/extractTankopedia.py index ca47685..6b398de 100644 --- a/extractTankopedia.py +++ b/extractTankopedia.py @@ -20,8 +20,8 @@ async def main(argv): parser = argparse.ArgumentParser(description='Extract Tankopedia data from Blitz game files') parser.add_argument('blitzAppBase', type=str, metavar="BLITZAPP_FOLDER", default=".", help='Base dir of the Blitz App files') - parser.add_argument('tanks', type=str, default='tanks.json',metavar="TANKS_FILE", help='File to write Tankopedia') - parser.add_argument('maps', type=str, default='maps.json', metavar='MAPS_FILE', help='File to write map names') + parser.add_argument('tanks', type=str, default='tanks.json', nargs='?', metavar="TANKS_FILE", help='File to write Tankopedia') + parser.add_argument('maps', type=str, default='maps.json', nargs='?', metavar='MAPS_FILE', help='File to write map names') parser.add_argument('-d', '--debug', action='store_true', default=False, help='Debug mode') parser.add_argument('-v', '--verbose', action='store_true', default=False, help='Verbose mode') diff --git a/wotbreplay_uploader.py b/wotbreplay_uploader.py index b57f28e..cda7dcf 100644 --- a/wotbreplay_uploader.py +++ b/wotbreplay_uploader.py @@ -31,14 +31,13 @@ async def main(argv): parser.add_argument('-t','--title', type=str, default=None, help='Title for replays. Use NN for continous numbering. Default is filename-based numbering') parser.add_argument('-p', '--private', dest="private", action='store_true', default=False, help='Set replays private on WoTinspector.com') parser.add_argument('--tasks', dest='N_tasks', type=int, default=10, help='Number of worker threads') - parser.add_argument('--tankopedia', type=str, default=None, help='JSON file to read Tankopedia from') - parser.add_argument('--mapfile', type=str, default=None, help='JSON file to read Blitz map names from') + parser.add_argument('--tankopedia', type=str, default='tanks.json', help='JSON file to read Tankopedia from. Default: "tanks.json"') + parser.add_argument('--mapfile', type=str, default='maps.json', help='JSON file to read Blitz map names from. Default: "maps.json"') parser.add_argument('-d', '--debug', action='store_true', default=False, help='Debug mode') parser.add_argument('-v', '--verbose', action='store_true', default=False, help='Verbose mode') parser.add_argument('files', metavar='FILE1 [FILE2 ...]', type=str, nargs='+', help='Files to read. Use \'-\' for STDIN"') args = parser.parse_args() - print(args.files) bu.setVerbose(args.verbose) bu.setDebug(args.debug) @@ -110,7 +109,6 @@ async def mkReplayQ(queue : asyncio.Queue, files : list, title : str): bu.debug('Finished') return None - async def mkQueueItem(filename : str, title : str) -> list: """Make an item to replay queue""" global REPLAY_N @@ -125,7 +123,6 @@ async def replayWorker(queue: asyncio.Queue, workerID: int, account_id: int, pri while True: item = await queue.get() filename = item[0] - # debug(filename) N = item[1] title = item[2] replay_json_fn = filename + '.json'