From d7fc664d3be4634a693a24fa98ff3f15d2c97c41 Mon Sep 17 00:00:00 2001 From: nico Date: Wed, 7 Nov 2018 00:37:24 +0100 Subject: * corrected CamelCase * corrected logging.INFO to .info * small changes to HandleError class --- classes/xep.py | 9 ++++----- common/misc.py | 6 +++--- main.py | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/classes/xep.py b/classes/xep.py index 98f4b78..a74c30f 100644 --- a/classes/xep.py +++ b/classes/xep.py @@ -1,8 +1,7 @@ -#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import requests -import defusedxml.ElementTree as et +import defusedxml.ElementTree as Et class XEPRequest: @@ -36,12 +35,12 @@ class XEPRequest: # compare etag with local_etag if they match up no request is made if local_etag == etag: with open("./common/xeplist.xml", "r") as file: - self.xeplist = et.fromstring(file.read()) + self.xeplist = Et.fromstring(file.read()) # if the connection is not possible use cached xml if present elif os.path.isfile("./common/xeplist.xml") and head.status_code != 200: with open("./common/xeplist.xml", "r") as file: - self.xeplist = et.fromstring(file.read()) + self.xeplist = Et.fromstring(file.read()) # in any other case request the latest xml else: @@ -51,7 +50,7 @@ class XEPRequest: with open("./common/xeplist.xml", "w") as file: file.write(r.content.decode()) - self.xeplist = et.fromstring(r.content.decode()) + self.xeplist = Et.fromstring(r.content.decode()) with open('./common/.etag', 'w') as string: string.write(local_etag) diff --git a/common/misc.py b/common/misc.py index bbf9c55..1350a2a 100755 --- a/common/misc.py +++ b/common/misc.py @@ -57,13 +57,13 @@ class HandleError: """ def __init__(self, error, key, target): # init all necessary variables - self.error = error + self.text = error.text + self.condition = error.condition self.key = key self.target = target def report(self): # return the formatted result string to the user - condition = self.error.condition - text = "There was an error requesting %s's %s : %s" % (self.target, self.key, condition) + text = "%s, %s resulted in: %s" % (self.text, self.key, self.condition) return text diff --git a/main.py b/main.py index 42d5349..5f8f220 100644 --- a/main.py +++ b/main.py @@ -60,6 +60,7 @@ class QueryBot(slixmpp.ClientXMPP): # If a room password is needed, use: password=the_room_password if self.room: for rooms in self.room.split(sep=","): + logging.debug("joining: %s" % rooms) self.plugin['xep_0045'].join_muc(rooms, self.nick, wait=True) async def message(self, msg): @@ -106,7 +107,7 @@ class QueryBot(slixmpp.ClientXMPP): query = await self['xep_0030'].get_info(jid=target, cached=False) except XMPPError as error: - logging.INFO(misc.HandleError(error, keyword, target).report()) + logging.info(misc.HandleError(error, keyword, target).report()) data['reply'].append(misc.HandleError(error, keyword, target).report()) continue -- cgit v1.2.3-54-g00ecf