1
0
Fork 0

Handle predbs being down.

This commit is contained in:
Casper V. Kristensen 2018-08-27 01:21:29 +02:00
parent 673e69802c
commit 6ec7c2a377
Signed by: caspervk
GPG key ID: B1156723DB3BDDA8
2 changed files with 11 additions and 1 deletions

View file

@ -44,6 +44,7 @@ class DailyReleasesBot(object):
def run(self):
mode = self.config["main"]["mode"]
logger.info("Mode is %s", mode)
if mode == "test":
self.generate(post=False)

View file

@ -1,6 +1,7 @@
import logging
from datetime import datetime
import requests
from bs4 import BeautifulSoup
logger = logging.getLogger(__name__)
@ -13,7 +14,15 @@ class Predb(object):
def get_releases(self):
logger.info("Getting releases from predbs")
return {**self._get_predbme(), **self._get_srrdb(), **self._get_xrel()} # in reverse order of preference
releases = {}
for db_releases in (self._get_predbme, self._get_srrdb, self._get_xrel): # in reverse order of preference
try:
releases.update(db_releases())
except requests.exceptions.ConnectionError as e:
logger.error(e)
logger.warning("Connection to predb failed, skipping..")
return releases
def _get_xrel(self, categories=("CRACKED", "UPDATE"), num_pages=2):
logger.debug("Getting releases from xrel.to")