diff --git a/src/add_soc.py b/src/add_soc.py index 829afa6..603a776 100644 --- a/src/add_soc.py +++ b/src/add_soc.py @@ -2,12 +2,14 @@ import os import re +import logging from typing import List import config from data_type import CoreInfo class Cores(object): + def __init__(self): self.submit_list = [] self.core_list = [] @@ -48,7 +50,7 @@ def add(self): def update(self): os.chdir(config.SUBMIT_DIR) # os.system('git checkout ' + config.CUR_BRAN) - print(f'git checkout {config.CUR_BRAN}') + # print(f'git checkout {config.CUR_BRAN}') with open(config.CORE_LIST_PATH, 'r+', encoding='utf-8') as fp: for v in fp.readlines(): tmp = v.split() @@ -70,8 +72,8 @@ def update(self): break if is_find is False: - # os.system(f'git clone {va.url} submit/{va.sid}') - print(f'git clone {va.url} submit/{va.sid}') + os.system(f'git clone {va.url} submit/{va.sid}') + # print(f'git clone {va.url} submit/{va.sid}') new_id.append(CoreInfo('', va.sid, 'F')) print(f'new core num: {len(new_id)}') @@ -87,10 +89,17 @@ def update(self): def main(): - print('[add soc]') - cores.clear() - cores.add() - cores.update() + logging.basicConfig(filename=config.RUN_LOG_PATH, filemode='w', format='%(asctime)s %(name)s:%(levelname)s:%(message)s', datefmt='%Y-%M-%d %H:%M:%S', level=logging.DEBUG) + logging.info('[add soc]') + logging.debug('This is a debug message') + logging.warning('This is a warning message') + logging.error('This is an error message') + logging.critical('This is a critical message') + + os.system(f'mkdir -p {config.DATA_DIR}') + # cores.clear() + # cores.add() + # cores.update() if __name__ == '__main__': diff --git a/src/config.py b/src/config.py index b5771de..ac9f89a 100644 --- a/src/config.py +++ b/src/config.py @@ -13,6 +13,7 @@ SUBMIT_LIST_PATH = DATA_DIR + '/submit_list' CORE_LIST_PATH = DATA_DIR + '/core_list' QUEUE_LIST_PATH = DATA_DIR + '/queue_list' +RUN_LOG_PATH = DATA_DIR + '/run.log' DC_HOME_DIR = HOME_DIR + '../lib/dc/bes_data/syn/scr' DC_LOG_DIR = DC_HOME_DIR + '../log' diff --git a/src/repo_update.py b/src/repo_update.py index 83458eb..2ff10d2 100644 --- a/src/repo_update.py +++ b/src/repo_update.py @@ -7,6 +7,7 @@ class CoreQueue(object): + def __init__(self): self.val_list = [] @@ -50,8 +51,8 @@ def check_remote_update(self, submod_name: str) -> (Tuple[bool, str]): # print(date_rev) date_rev = config.exec_cmd(cmd) - std_date = datetime.strptime( - date_rev, config.GMT_FORMAT).strftime(config.STD_FOMRAT) + std_date = datetime.strptime(date_rev, config.GMT_FORMAT).strftime( + config.STD_FOMRAT) os.chdir(config.HOME_DIR) print(submod_name + ':') @@ -133,7 +134,7 @@ def main(): print('[repo update]') core_queue.clear() core_queue.check_id() - core_queue.update_queue() + # core_queue.update_queue() if __name__ == '__main__': diff --git a/src/task.py b/src/task.py index 3c1c6c2..46a2b2f 100755 --- a/src/task.py +++ b/src/task.py @@ -1,6 +1,8 @@ #!/bin/python import time +import config +import logging import schedule import add_soc import repo_update @@ -16,10 +18,13 @@ # toml, database def main_task(): add_soc.main() - repo_update.main() - dispatch.main() + # repo_update.main() + # dispatch.main() +logging.basicConfig(filename=config.RUN_LOG_PATH, filemode='w', + format='%(asctime)s %(name)s:%(levelname)s:%(message)s', + datefmt='%Y-%M-%d %H:%M:%S', level=logging.DEBUG) schedule.every(1).seconds.do(main_task) while True: