разделил создание зависимостей и сценарий переноса трудочасов, переименовал основную точку входа в main.py
This commit is contained in:
59
main.py
Normal file
59
main.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import logging
|
||||
import sys
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s %(name)s:%(lineno)d %(levelname)s %(message)s',
|
||||
handlers=[
|
||||
logging.FileHandler('app.log', encoding='utf-8'),
|
||||
logging.StreamHandler(sys.stdout)
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
from api.clockify import ClockifyAPI # noqa: E402
|
||||
from api.redmine import RedmineAPI # noqa: E402
|
||||
from config import arg_parser, config # noqa: E402
|
||||
from db.db import Database # noqa: E402
|
||||
from services.tracking import TrackingService # noqa: E402
|
||||
from utils import check_envs, db_update, get_start_end_dates # noqa: E402
|
||||
|
||||
|
||||
def main():
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
if is_debug := args.debug:
|
||||
config.MODE = "debug"
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
db = Database(config.DB_NAME, config.SQL_PATH)
|
||||
red = RedmineAPI(config.REDMINE_TOKEN)
|
||||
clock = ClockifyAPI(
|
||||
token=config.CLOCKIFY_TOKEN,
|
||||
workspace_id=config.WORKSPACE_ID,
|
||||
user_id=config.USER_ID,
|
||||
db=db,
|
||||
redmine_api=red,
|
||||
)
|
||||
|
||||
start, end = get_start_end_dates(args)
|
||||
|
||||
if not check_envs(clock):
|
||||
return
|
||||
|
||||
if args.init_db:
|
||||
db_update(clock, db, red)
|
||||
|
||||
try:
|
||||
TrackingService(
|
||||
clock=clock,
|
||||
red=red,
|
||||
db=db,
|
||||
is_debug=is_debug,
|
||||
).track_period(start=start, end=end, page_size=args.page_size)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user