def collect_oneday(d): data_path = os.path.join(DATA_DEST_ROOT, d) if not os.path.exists(data_path): os.mkdir(data_path) src_dir = os.path.join(DATA_SRC_ROOT, d) if not os.path.exists(src_dir): raise ValueError("Wrong directory: %s" % src_dir) for k in os.listdir(src_dir): if APP in k: f = ''.join([src_dir, '/', k, '/', 'ledo_game.log']) if os.path.isfile(f): copyfile(f, ''.join([data_path, '/', k, '_ledo_game.log'])) ext = Extract(d, DATA_DEST_ROOT) ext.run_extract_dir() rmtree(data_path, True)
def update_today_db(update=False, date=None): ''' update the datebase info ''' if date is None: date = get_today_date() ext = Extract(date, DATA_DEST_ROOT) data_path = os.path.join(DATA_DEST_ROOT, get_today_date()) if not os.path.exists(data_path): os.mkdir(data_path) src_dir = os.path.join(DATA_SRC_ROOT, get_today_date()) if not os.path.exists(src_dir): raise ValueError("directory(%s) doesn't existed" % src_dir) files = os.listdir(data_path) for k in os.listdir(src_dir): f = ''.join([k, '_ledo_game.log']) if APP in k and f not in files: src_file = ''.join([src_dir, '/', k, '/', 'ledo_game.log']) if os.path.isfile(src_file): new_name = ''.join([data_path, '/', f]) copyfile(src_file, new_name) if update: ext.run_extract_file(new_name) if not update: ext.run_extract_dir() ext.run_end() return True