From 00ae6f8e46ba08283034920dcb7c113897f144c1 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 17 Apr 2012 20:05:02 -0400 Subject: [PATCH] Code cleanup and bugfixes --- earwigbot/commands/praise.py | 2 -- earwigbot/config.py | 4 ++-- earwigbot/wiki/site.py | 2 +- earwigbot/wiki/sitesdb.py | 8 +++----- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/earwigbot/commands/praise.py b/earwigbot/commands/praise.py index fb611f5..5532cc7 100644 --- a/earwigbot/commands/praise.py +++ b/earwigbot/commands/praise.py @@ -20,8 +20,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import random - from earwigbot.commands import BaseCommand class Command(BaseCommand): diff --git a/earwigbot/config.py b/earwigbot/config.py index 59392a1..d3aaad2 100644 --- a/earwigbot/config.py +++ b/earwigbot/config.py @@ -90,7 +90,7 @@ class BotConfig(object): with open(filename, 'r') as fp: try: self._data = yaml.load(fp) - except yaml.YAMLError as error: + except yaml.YAMLError: print "Error parsing config file {0}:".format(filename) raise @@ -137,7 +137,7 @@ class BotConfig(object): """Try to decrypt the contents of a config node. Use self.decrypt().""" try: node._decrypt(self._decryption_key, nodes[:-1], nodes[-1]) - except blowfish.BlowfishError as error: + except blowfish.BlowfishError: print "Error decrypting passwords:" raise diff --git a/earwigbot/wiki/site.py b/earwigbot/wiki/site.py index a0dbc61..bdea9e6 100644 --- a/earwigbot/wiki/site.py +++ b/earwigbot/wiki/site.py @@ -138,7 +138,7 @@ class Site(object): if logger: self._logger = logger else: # Just set up a null logger to eat up our messages: - self._logger = getLogger("earwigbot.wiki").getChild(self._name) + self._logger = getLogger("earwigbot.wiki") self._logger.addHandler(NullHandler()) # If we have a name/pass and the API says we're not logged in, log in: diff --git a/earwigbot/wiki/sitesdb.py b/earwigbot/wiki/sitesdb.py index dcdcf1e..2a3cba5 100644 --- a/earwigbot/wiki/sitesdb.py +++ b/earwigbot/wiki/sitesdb.py @@ -22,7 +22,6 @@ from cookielib import LWPCookieJar, LoadError import errno -from getpass import getpass from os import chmod, path from platform import python_version import stat @@ -87,8 +86,8 @@ class SitesDB(object): if e.errno == errno.ENOENT: # "No such file or directory" # Create the file and restrict reading/writing only to the # owner, so others can't peak at our cookies: - open(cookie_file, "w").close() - chmod(cookie_file, stat.S_IRUSR|stat.S_IWUSR) + open(self._cookie_file, "w").close() + chmod(self._cookie_file, stat.S_IRUSR|stat.S_IWUSR) else: raise @@ -344,7 +343,6 @@ class SitesDB(object): assert_edit = config.wiki.get("assert") maxlag = config.wiki.get("maxlag") wait_between_queries = config.wiki.get("waitTime", 5) - logger = self._logger.getChild(name) search_config = config.wiki.get("search") # Create a Site object to log in and load the other attributes: @@ -352,7 +350,7 @@ class SitesDB(object): login=login, cookiejar=cookiejar, user_agent=user_agent, use_https=use_https, assert_edit=assert_edit, maxlag=maxlag, wait_between_queries=wait_between_queries, - logger=logger, search_config=search_config) + search_config=search_config) self._add_site_to_sitesdb(site) self._sites[site.name()] = site