Started working on post-crawl callbacks and basic auth for crawl servers

This commit is contained in:
Simon
2018-06-14 15:05:56 -04:00
parent 1bd58468eb
commit 83ca579ec7
13 changed files with 142 additions and 56 deletions

11
task.py
View File

@@ -4,14 +4,14 @@ from crawl_server.database import Task, TaskResult
import requests
from requests.exceptions import ConnectionError
import json
from reddit_bot import RedditBot
import praw
import config
class CrawlServer:
headers = {
"Content-Type": "application/json"
"Content-Type": "application/json",
"Authorization": "Token " + config.CRAWL_SERVER_TOKEN,
}
def __init__(self, url):
@@ -73,11 +73,6 @@ class CrawlServer:
class TaskDispatcher:
def __init__(self):
# TODO: remove reddit
reddit = praw.Reddit('opendirectories-bot',
user_agent='github.com/simon987/od-database v1.0 (by /u/Hexahedr_n)')
self.reddit_bot = RedditBot("crawled.txt", reddit)
scheduler = BackgroundScheduler()
scheduler.add_job(self.check_completed_tasks, "interval", seconds=1)
scheduler.start()