diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-28 15:20:26 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-28 15:20:26 +0200 |
commit | 9dc5ea0e947832e8c682c68df0aadbdc4bb27fa0 (patch) | |
tree | 03d65d4ae09ddf5403f711055e2202a166acdc4c | |
parent | Bugfix. (diff) | |
download | newspipe-9dc5ea0e947832e8c682c68df0aadbdc4bb27fa0.tar.gz newspipe-9dc5ea0e947832e8c682c68df0aadbdc4bb27fa0.tar.bz2 newspipe-9dc5ea0e947832e8c682c68df0aadbdc4bb27fa0.zip |
more tests
-rw-r--r-- | src/bootstrap.py | 2 | ||||
-rw-r--r-- | src/crawler/classic_crawler.py | 4 | ||||
-rw-r--r-- | src/web/controllers/abstract.py | 5 |
3 files changed, 8 insertions, 3 deletions
diff --git a/src/bootstrap.py b/src/bootstrap.py index 8aaba976..7b6a6c8c 100644 --- a/src/bootstrap.py +++ b/src/bootstrap.py @@ -15,7 +15,7 @@ def set_logging(log_path, log_level=logging.INFO, formater = logging.Formatter(log_format) handler = logging.FileHandler(log_path) handler.setFormatter(formater) - for logger_name in ('bootstrap', 'web', 'manager', 'runserver'): + for logger_name in ('bootstrap', 'web', 'manager', 'runserver', 'classic_crawler'): logger = logging.getLogger(logger_name) logger.addHandler(handler) logger.setLevel(log_level) diff --git a/src/crawler/classic_crawler.py b/src/crawler/classic_crawler.py index 2e292624..1105ed87 100644 --- a/src/crawler/classic_crawler.py +++ b/src/crawler/classic_crawler.py @@ -112,7 +112,7 @@ async def insert_database(user, feed): if None is articles: return [] - logger.debug('inserting articles for {}'.format(feed.title)) + logger.info('inserting articles for {}'.format(feed.title)) logger.info("Database insertion...") new_articles = [] @@ -131,6 +131,8 @@ async def insert_database(user, feed): # the content or the title logger.debug("Article %r (%r) already in the database.", article['title'], article['link']) + print("Article %r (%r) already in the database.", + article['title'], article['link']) existing_article = existing_article_req.first() new_updated_date = None try: diff --git a/src/web/controllers/abstract.py b/src/web/controllers/abstract.py index 2a2e6f9f..5cebd39e 100644 --- a/src/web/controllers/abstract.py +++ b/src/web/controllers/abstract.py @@ -91,7 +91,10 @@ class AbstractController: obj = self._db_cls(**attrs) db.session.add(obj) - db.session.commit() + try: + db.session.commit() + except Exception as e: + logger.exception(str(e)) return obj def read(self, **filters): |