report_path = config['report_path'] if 'report_path' in config else None latest_backup_symlink = config[ 'latest_backup_symlink'] if 'latest_backup_symlink' in config else None if not os.path.isdir(backup_dir): os.makedirs(backup_dir) a = Authenticator(event_name, c2_login, c2_password, interactive=False) if not a.sign_in(): exit() f = Fetcher(a.event_name, a.cookie) if not f.fetch_data(): exit() f.fetch_etickets() f.fetch_details() db_path = os.path.join(backup_dir, datetime.now().strftime('%y-%m-%d_%H-%M-%S.db')) MakeDB(db_path, f.data) if latest_backup_symlink: os.remove(latest_backup_symlink) if os.path.exists( latest_backup_symlink) else None try: os.symlink(db_path, latest_backup_symlink) except OSError: print('[WARNING] Failed to create a latest_backup_symlink!') if report_path: print('Validating...')
all_data = len(sys.argv) > 1 and sys.argv[1] == '-a' a = Authenticator(event_name, c2_login, c2_password) if not a.sign_in(): exit() print() f = Fetcher(a.event_name, a.cookie) if not f.fetch_data(): exit() if all_data: if not f.fetch_etickets(): exit() if not f.fetch_details(): exit() print('\nCreating ' + db_path + '...') MakeDB(db_path, f.data) if sql: from tabulate import tabulate print('\nConnecting to ' + db_path + ' again...') with sqlite3.connect(db_path, isolation_level=None) as db: c = db.cursor() c.execute('PRAGMA encoding = "UTF-8"') c.execute(sql) print( tabulate(