def main(): utils.SetWorkingDirectory(__file__) utils.Log('Clearing the last draw database') f = open('draw_database_last.txt', 'w') file_list = glob.glob(os.path.join('UTC_logs', 'UTC_log*.log')) for filename in file_list: parsefile.ProcessFile(filename, verbose=False, append_production=True) utils.ArchiveUTClog(filename)
def main(): utils.Log('Looking for logs in {0}\n'.format(source_dir)) utils.SetWorkingDirectory(__file__) try: file_list = glob.glob(os.path.join(source_dir, 'UTC_log*.log')) except: utils.Log('Cannot get list of files at: {0}\n'.format(source_dir)) raise existing_file_list_1 = glob.glob(os.path.join('UTC_logs', 'UTC_log*.log')) existing_file_list_2 = glob.glob( os.path.join('UTC_logs', 'parsed', 'UTC_log*.log')) existing = existing_file_list_1 + existing_file_list_2 existing = [os.path.basename(x) for x in existing] for filename in file_list: basename = os.path.basename(filename) if basename in existing: utils.Log('Already in UTC_Logs, or parsed: {0}\n'.format(basename)) else: utils.Log('Attempting copy: {0}\n'.format(filename)) shutil.copyfile(filename, os.path.join('UTC_logs', basename))
""" Script to generate mega-summary """ import glob import os import traceback import parsercode.utils as utils if __name__ == '__main__': utils.Log('Starting\n') try: utils.SetWorkingDirectory(__file__) utils.SumUpAllUserData('all_user_aggregates.txt') except Exception as ex: utils.Log(traceback.format_exc() + '\n') raise
def main(): utils.Log('Looking for logs in {0}\n'.format(source_dir)) utils.SetWorkingDirectory(__file__) try: file_list = glob.glob(os.path.join(source_dir, 'UTC_log*.log')) except: utils.Log('Cannot get list of files at: {0}\n'.format(source_dir)) raise existing_file_list_1 = glob.glob(os.path.join('UTC_logs', 'UTC_log*.log')) existing_file_list_2 = glob.glob( os.path.join('UTC_logs', 'parsed', 'UTC_log*.log')) existing = existing_file_list_1 + existing_file_list_2 existing = [os.path.basename(x) for x in existing] for filename in file_list: basename = os.path.basename(filename) if basename in existing: utils.Log('Already in UTC_Logs, or parsed: {0}\n'.format(basename)) else: utils.Log('Attempting copy: {0}\n'.format(filename)) shutil.copyfile(filename, os.path.join('UTC_logs', basename)) if __name__ == '__main__': try: utils.Log('Trying to copy log (new) log files.\n') main() except Exception as ex: utils.Log(traceback.format_exc() + '\n') raise
""" Debugging version. Doesn't write to draws.txt, but draws_debug.txt """ import parsercode.utils as utils if __name__ == '__main__': utils.Log('Starting\n') try: f = open('draws_debug.txt', 'w') f.close() utils.ProcessFile('output_log.txt', debug=True, verbose=True) except Exception as ex: utils.Log('{0}\n'.format(ex)) raise
""" Process all logs in archive Only need to use this if rebuilding draws.txt Writes to draws_debug.txt """ import glob import os import parsercode.utils as utils if __name__ == '__main__': utils.Log('Starting\n') # Clear the debug file. f = open('draws_debug.txt', 'w') f.close() file_list = glob.glob(os.path.join('archive', 'output_log*.txt')) for filename in file_list: try: utils.ProcessFile(filename, debug=True, verbose=False) except Exception as ex: utils.Log(str(ex)) raise
""" import json import glob import os import traceback import pprint import parsercode.utils as utils import parsercode.parsefile as parsefile if __name__ == '__main__': utils.Log('Starting\n') try: utils.SetWorkingDirectory(__file__) land_mapping = utils.LoadLandMapping() utils.Log('Initial entries: {0}\n'.format(len(land_mapping))) try: f_in = open('database.json', 'r') except: input( 'Need to get database.json from MTGA Tool repository. Hit return to quit >' ) raise info = json.load(f_in) cardz = info['cards'] for k in cardz: num_id = cardz[k]['id']
""" Debugging version of draw database """ import glob import os import traceback import parsercode.utils as utils import parsercode.parsefile as parsefile if __name__ == '__main__': utils.Log('Starting\n') try: utils.SetWorkingDirectory(__file__) utils.Log('Clearing the last draw database') f = open('draw_database_last.txt', 'w') parsefile.ProcessFile('output_log.txt', verbose=True, append_production=False) except Exception as ex: utils.Log(traceback.format_exc() + '\n') raise
NOTE: Mulligan tracking fixed. No idea whether Bo3 will work. """ import os import sys import traceback import parsercode.utils as utils import parsercode.parsefile as parsefile if __name__ == '__main__': utils.Log('Starting\n') try: if not os.path.exists('output_log.txt'): utils.Log( 'Arena log file "output_log.txt" not in running directory (same as this file)' ) utils.Log('Current working directory = {0}\n'.format(os.getcwd())) o = input('Hit return to continue >') else: utils.ProcessFile('output_log.txt') except Exception as ex: utils.Log(traceback.format_exc() + '\n') traceback.print_exc(file=sys.stdout) o = input('Hit return to continue >') raise