diff --git a/app.py b/app.py index 8a71538..028b365 100644 --- a/app.py +++ b/app.py @@ -18,8 +18,11 @@ api.setup_api(app) if os.environ.get("ODDB_USER", False) and os.environ.get("ODDB_PASSWORD", False): user = os.environ["ODDB_USER"] password = os.environ["ODDB_PASSWORD"] - common.db.generate_login(user, password) - print("Generated user %s" % user) + try: + common.db.generate_login(user, password) + print("Generated user %s" % user) + except: + pass if __name__ == '__main__': app.run("0.0.0.0", port=80, threaded=True) diff --git a/config.py b/config.py index 9993f3e..427e90a 100644 --- a/config.py +++ b/config.py @@ -16,7 +16,7 @@ TT_CRAWL_PROJECT = int(environ.get("TT_CRAWL_PROJECT", 3)) TT_INDEX_PROJECT = int(environ.get("TT_INDEX_PROJECT", 9)) WSB_API = environ.get("WSB_API", "http://localhost:3020") -WSB_SECRET = environ.get("WSB_API", "default_secret") +WSB_SECRET = environ.get("WSB_SECRET", "default_secret") ES_URL = environ.get("ES_URL", "http://localhost:9200") ES_INDEX = environ.get("ES_INDEX", "od-database") diff --git a/database.py b/database.py index c01be5c..587d503 100644 --- a/database.py +++ b/database.py @@ -121,8 +121,9 @@ class Database: cursor = conn.cursor() cursor.execute("SELECT id FROM Website ORDER BY random() LIMIT 1") - if cursor.fetchone(): - return cursor.fetchone()[0] + row = cursor.fetchone() + if row: + return row[0] return None def website_exists(self, url): diff --git a/tasks.py b/tasks.py index 7d19685..f3a2b67 100644 --- a/tasks.py +++ b/tasks.py @@ -11,7 +11,6 @@ from uuid import uuid4 import requests import urllib3 -import common import config import database from database import Website @@ -75,13 +74,12 @@ class TaskManager: if not self.worker: self.worker = self.tracker.make_worker("$oddb_master") if not self.worker: - common.logger.error("Could not create worker: %s" % traceback.format_exc()) + print("Could not create worker: %s" % traceback.format_exc()) return self.worker.dump_to_file() self.worker.request_access(config.TT_CRAWL_PROJECT, False, True) self.worker.request_access(config.TT_INDEX_PROJECT, True, False) - def start_indexer_threads(self): logger.info("Starting %s indexer threads " % (config.INDEXER_THREADS, )) for _ in range(config.INDEXER_THREADS):