-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (36 loc) · 1.2 KB
/
main.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
34
35
36
37
38
39
40
41
42
43
44
45
import logging
import praw
import yaml
from src.reddit import RedditService
from src.db import DbService
from src.db.couchdb import CouchdbService
from src.executor import Executor
import coloredlogs
def configure_logging():
coloredlogs.install(
level='INFO',
fmt='%(asctime)s, %(levelname)s %(message)s',
logger=logging.getLogger()
)
with open("configs.yaml", 'r') as stream:
config = yaml.safe_load(stream)
reddit = RedditService(praw.Reddit())
couchdb_engine = CouchdbService(
url=config['couchdb']['host'],
user=config['couchdb']['username'],
password=config['couchdb']['password']
)
db = DbService(couchdb_engine)
if __name__ == "__main__":
configure_logging()
app_config = config['app']
executor = Executor(
reddit=reddit,
db=db,
running_window=(app_config['running_window_start_hour'], app_config['running_window_end_hour']),
min_reposting_delay=app_config['min_reposting_delay'],
max_reposting_delay=app_config['max_reposting_delay'],
subreddit_frontpage_shreshold=app_config['subreddit_frontpage_shreshold'],
run_interval_seconds=app_config['run_interval_seconds']
)
executor.run()