diff --git a/.travis.yml b/.travis.yml index e1d0a77..9dfde96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ python: install: - pip install flake8 - - npm install jshint + - npm -g install jshint script: - flake8 server/ --max-line-length=85 diff --git a/server/models.py b/server/models.py index dae1c1a..fa235a6 100644 --- a/server/models.py +++ b/server/models.py @@ -23,6 +23,7 @@ def db_session(): finally: session.close() + Base = declarative_base() Base.query = scoped_session(sessionmaker(autocommit=False, autoflush=False, diff --git a/server/settings.py b/server/settings.py index 030ee55..866c203 100644 --- a/server/settings.py +++ b/server/settings.py @@ -10,6 +10,7 @@ def get_env_variable(name, default=None): else: return default + MODEL_DEF_PATH = get_env_variable("MODEL_DEF_PATH") PRETRAINED_MODEL_PATH = get_env_variable("PRETRAINED_MODEL_PATH") diff --git a/server/tasks.py b/server/tasks.py index 8398d3e..3a4d815 100644 --- a/server/tasks.py +++ b/server/tasks.py @@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) -TWITTER_RE = re.compile(".+>([a-zA-Z0-9\./]+)<.+") +TWITTER_RE = re.compile(".+>([a-zA-Z0-9./]+)<.+") INSTAGRAM_API = "https://api.instagram.com/oembed/?callback=&url=%s" @@ -101,8 +101,8 @@ def img_and_not_szerzo(tag): for f in [extract_instagram_urls, extract_twitter_urls, ]: try: images.extend(f(soup, link)) - except: - logger.error("Error calling '%s' with '%s'", f, link) + except Exception: + logger.exception("Error calling '%s' with '%s'", f, link) logger.info("Scanning '%s' finished, found the following images: %s", link, ",".join(images)) diff --git a/server/web.py b/server/web.py index 130b351..ed913b1 100644 --- a/server/web.py +++ b/server/web.py @@ -21,7 +21,7 @@ def home(): @app.route('/get_scores/', methods=['GET', 'POST', ]) def get_scores(): - article_urls = request.get_json() + article_urls = request.get_json() or [] key = sha.new("".join(article_urls)).hexdigest() result = redis_store.get(key) if not result: