-
Notifications
You must be signed in to change notification settings - Fork 0
/
exec.py
33 lines (26 loc) · 916 Bytes
/
exec.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import time
from datetime import datetime
import schedule
from analyzer import BangumiAnalyzer
from conf import conf
from crawler import BangumiCrawler
from db import MongoDB
from utils import logger
if __name__ == '__main__':
logger.info('Hello! This is Bangumi-Provider :)')
client = MongoDB(conf)
crawler = BangumiCrawler(client, conf)
analyzer = BangumiAnalyzer(client, conf)
def jobs():
crawler.crawl()
analyzer.analyze()
if conf.SCHEDULE_ENABLE:
logger.info('Running with Schedule Enabled, Tasks Schedule Every Day. Now: %s, Next Schedule: %s.' %
(datetime.now(), conf.SCHEDULE_CRON_AT))
schedule.every().day.at(conf.SCHEDULE_CRON_AT).do(jobs)
while True:
schedule.run_pending()
time.sleep(1)
else:
logger.info('Running with Schedule Disabled, Start Tasks Directly.')
jobs()