59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
import logging
|
||
import sys
|
||
|
||
from api import ClockifyAPI, RedmineAPI
|
||
from config import arg_parser, config
|
||
from utils import format_date, str_to_date, today_start, today_end
|
||
|
||
|
||
WORKSPACE_ID = config.CLOCKIFY_WORKSPACE_ID
|
||
USER_ID = config.CLOCKIFY_USER_ID
|
||
|
||
|
||
def main():
|
||
args = arg_parser.parse_args()
|
||
start, end = None, None
|
||
if args.start:
|
||
start = str_to_date(args.start)
|
||
if args.end:
|
||
end = str_to_date(args.end)
|
||
if args.start is None and args.end is None:
|
||
logging.info("Парсим задачи за сегодняшний день")
|
||
start = today_start()
|
||
end = today_end()
|
||
else:
|
||
logging.info("Парсим задачи" + (f" с {start.date()} " if start else " ") + (f"до {end.date()}" if end else ""))
|
||
|
||
clock = ClockifyAPI(
|
||
token=config.CLOCKIFY_TOKEN,
|
||
workspace_id=WORKSPACE_ID,
|
||
user_id=USER_ID
|
||
)
|
||
red = RedmineAPI(config.REDMINE_TOKEN)
|
||
activities = clock.get_activities(
|
||
**{
|
||
"start": format_date(start),
|
||
"end": format_date(end),
|
||
"page-size": args.page_size,
|
||
},
|
||
)
|
||
# tracked_activities = red.track_activities(activities)
|
||
# clock.mark_tracked(tracked_activities)
|
||
for activity in activities:
|
||
print(activity)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
logging.basicConfig(
|
||
level=logging.INFO,
|
||
format=('%(asctime)s, '
|
||
'%(levelname)s, '
|
||
'%(funcName)s, '
|
||
'%(message)s'
|
||
),
|
||
encoding='UTF-8',
|
||
handlers=[logging.FileHandler(__file__ + '.log'),
|
||
logging.StreamHandler(sys.stdout)]
|
||
)
|
||
main()
|