Skip to content

Commit

Permalink
feat: add log module
Browse files Browse the repository at this point in the history
  • Loading branch information
maksyuki committed Feb 23, 2024
1 parent 683504b commit 0f0355d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
23 changes: 16 additions & 7 deletions src/add_soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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()
Expand All @@ -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)}')
Expand All @@ -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__':
Expand Down
1 change: 1 addition & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 4 additions & 3 deletions src/repo_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class CoreQueue(object):

def __init__(self):
self.val_list = []

Expand Down Expand Up @@ -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 + ':')
Expand Down Expand Up @@ -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__':
Expand Down
9 changes: 7 additions & 2 deletions src/task.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/python

import time
import config
import logging
import schedule
import add_soc
import repo_update
Expand All @@ -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:
Expand Down

0 comments on commit 0f0355d

Please sign in to comment.