Made the script aware then the wiki domain is incorrect

This commit is contained in:
Frisk 2018-06-25 14:49:55 +02:00
parent e69e342df1
commit fe5737deca
No known key found for this signature in database
GPG key ID: 0E9A7D3C0A01586C

View file

@ -20,7 +20,7 @@
#WARNING! SHITTY CODE AHEAD. ENTER ONLY IF YOU ARE SURE YOU CAN TAKE IT #WARNING! SHITTY CODE AHEAD. ENTER ONLY IF YOU ARE SURE YOU CAN TAKE IT
#You have been warned #You have been warned
import time, logging, json, requests, datetime, re, gettext, math, random, os.path, schedule import time, logging, json, requests, datetime, re, gettext, math, random, os.path, schedule, sys
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from collections import defaultdict, Counter from collections import defaultdict, Counter
from urllib.parse import quote_plus from urllib.parse import quote_plus
@ -57,7 +57,7 @@ def safe_read(request, *keys):
logging.warning("Failure while extracting data from request on key {key} in {change}".format(key=item, change=request)) logging.warning("Failure while extracting data from request on key {key} in {change}".format(key=item, change=request))
return None return None
except ValueError: except ValueError:
logging.warning("Failure while extracting data from request in {change}".format(key=item, change=request)) logging.warning("Failure while extracting data from request in {change}".format(change=request))
return None return None
return request return request
@ -600,6 +600,9 @@ class recent_changes_class(object):
changes.reverse() changes.reverse()
except ValueError: except ValueError:
logging.warning("ValueError in fetching changes") logging.warning("ValueError in fetching changes")
if changes.url == "https://www.gamepedia.com":
logging.critical("The wiki specified in the settings most probably doesn't exist, got redirected to gamepedia.com")
sys.exit(1)
self.downtime_controller() self.downtime_controller()
return None return None
except KeyError: except KeyError: