mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Very small fixes
This commit is contained in:
parent
321e7ffedb
commit
ca43ffbed8
11
src/bot.py
11
src/bot.py
|
@ -133,8 +133,7 @@ async def wiki_scanner():
|
|||
await formatter_exception_logger(db_wiki["wiki"], change, traceback.format_exc())
|
||||
if recent_changes:
|
||||
DBHandler.add(db_wiki["wiki"], change["rcid"])
|
||||
DBHandler.update_db()
|
||||
await asyncio.sleep(delay=calc_delay)
|
||||
await asyncio.sleep(delay=2.0) # temporary measure until rate limiting is not implemented
|
||||
if db_wiki["wikiid"] is not None:
|
||||
header = settings["header"]
|
||||
header["Accept"] = "application/hal+json"
|
||||
|
@ -142,8 +141,6 @@ async def wiki_scanner():
|
|||
timeout=aiohttp.ClientTimeout(3.0)) as session:
|
||||
try:
|
||||
feeds_response = await local_wiki.fetch_feeds(db_wiki["wikiid"], session)
|
||||
# await local_wiki.check_status(db_wiki["wiki"], wiki_response.status)
|
||||
# NEED A GOAT TO CHECK THIS
|
||||
except (WikiServerError, WikiError):
|
||||
logger.error("Exeption when fetching the wiki")
|
||||
continue # ignore this wiki if it throws errors
|
||||
|
@ -161,8 +158,6 @@ async def wiki_scanner():
|
|||
discussion_feed.reverse()
|
||||
except aiohttp.ContentTypeError:
|
||||
logger.exception("Wiki seems to be resulting in non-json content.")
|
||||
# NEED A GOAT TO CHECK THIS
|
||||
# await local_wiki.fail_add(db_wiki["wiki"], 410)
|
||||
continue
|
||||
except:
|
||||
logger.exception("On loading json of response.")
|
||||
|
@ -188,8 +183,8 @@ async def wiki_scanner():
|
|||
await formatter_exception_logger(db_wiki["wiki"], post, traceback.format_exc())
|
||||
if discussion_feed:
|
||||
DBHandler.add(db_wiki["wiki"], post["id"], True)
|
||||
DBHandler.update_db()
|
||||
await asyncio.sleep(delay=calc_delay)
|
||||
await asyncio.sleep(delay=calc_delay)
|
||||
DBHandler.update_db()
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
|
||||
|
|
|
@ -16,10 +16,8 @@ class UpdateDB:
|
|||
|
||||
def update_db(self):
|
||||
for update in self.updated:
|
||||
id = "rcid"
|
||||
if update[2] is not None:
|
||||
id = "postid"
|
||||
db_cursor.execute("UPDATE rcgcdw SET {} = ? WHERE wiki = ?".format(id),(update[1],update[0],))
|
||||
update_type = "postid" if update[2] is not None else "rcid"
|
||||
db_cursor.execute("UPDATE rcgcdw SET {} = ? WHERE wiki = ?".format(update_type), (update[1],update[0],))
|
||||
db_connection.commit()
|
||||
self.clear_list()
|
||||
|
||||
|
|
|
@ -56,7 +56,8 @@ class Wiki:
|
|||
params = {"sortDirection": "descending", "sortKey": "creation_date", "limit": 20}
|
||||
try:
|
||||
response = await session.get(url_path, params=params)
|
||||
except (aiohttp.ClientConnectionError, aiohttp.ServerTimeoutError, asyncio.TimeoutError):
|
||||
response.raise_for_status()
|
||||
except (aiohttp.ClientConnectionError, aiohttp.ServerTimeoutError, asyncio.TimeoutError, aiohttp.ClientResponseError):
|
||||
logger.exception("A connection error occurred while requesting {}".format(url_path))
|
||||
raise WikiServerError
|
||||
return response
|
||||
|
|
Loading…
Reference in a new issue