Browse Source

Code cleanup and bugfixes

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
00ae6f8e46
4 changed files with 6 additions and 10 deletions
  1. +0
    -2
      earwigbot/commands/praise.py
  2. +2
    -2
      earwigbot/config.py
  3. +1
    -1
      earwigbot/wiki/site.py
  4. +3
    -5
      earwigbot/wiki/sitesdb.py

+ 0
- 2
earwigbot/commands/praise.py View File

@@ -20,8 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.


import random

from earwigbot.commands import BaseCommand from earwigbot.commands import BaseCommand


class Command(BaseCommand): class Command(BaseCommand):


+ 2
- 2
earwigbot/config.py View File

@@ -90,7 +90,7 @@ class BotConfig(object):
with open(filename, 'r') as fp: with open(filename, 'r') as fp:
try: try:
self._data = yaml.load(fp) self._data = yaml.load(fp)
except yaml.YAMLError as error:
except yaml.YAMLError:
print "Error parsing config file {0}:".format(filename) print "Error parsing config file {0}:".format(filename)
raise raise


@@ -137,7 +137,7 @@ class BotConfig(object):
"""Try to decrypt the contents of a config node. Use self.decrypt().""" """Try to decrypt the contents of a config node. Use self.decrypt()."""
try: try:
node._decrypt(self._decryption_key, nodes[:-1], nodes[-1]) node._decrypt(self._decryption_key, nodes[:-1], nodes[-1])
except blowfish.BlowfishError as error:
except blowfish.BlowfishError:
print "Error decrypting passwords:" print "Error decrypting passwords:"
raise raise




+ 1
- 1
earwigbot/wiki/site.py View File

@@ -138,7 +138,7 @@ class Site(object):
if logger: if logger:
self._logger = logger self._logger = logger
else: # Just set up a null logger to eat up our messages: 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()) self._logger.addHandler(NullHandler())


# If we have a name/pass and the API says we're not logged in, log in: # If we have a name/pass and the API says we're not logged in, log in:


+ 3
- 5
earwigbot/wiki/sitesdb.py View File

@@ -22,7 +22,6 @@


from cookielib import LWPCookieJar, LoadError from cookielib import LWPCookieJar, LoadError
import errno import errno
from getpass import getpass
from os import chmod, path from os import chmod, path
from platform import python_version from platform import python_version
import stat import stat
@@ -87,8 +86,8 @@ class SitesDB(object):
if e.errno == errno.ENOENT: # "No such file or directory" if e.errno == errno.ENOENT: # "No such file or directory"
# Create the file and restrict reading/writing only to the # Create the file and restrict reading/writing only to the
# owner, so others can't peak at our cookies: # 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: else:
raise raise


@@ -344,7 +343,6 @@ class SitesDB(object):
assert_edit = config.wiki.get("assert") assert_edit = config.wiki.get("assert")
maxlag = config.wiki.get("maxlag") maxlag = config.wiki.get("maxlag")
wait_between_queries = config.wiki.get("waitTime", 5) wait_between_queries = config.wiki.get("waitTime", 5)
logger = self._logger.getChild(name)
search_config = config.wiki.get("search") search_config = config.wiki.get("search")


# Create a Site object to log in and load the other attributes: # 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, login=login, cookiejar=cookiejar, user_agent=user_agent,
use_https=use_https, assert_edit=assert_edit, use_https=use_https, assert_edit=assert_edit,
maxlag=maxlag, wait_between_queries=wait_between_queries, 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._add_site_to_sitesdb(site)
self._sites[site.name()] = site self._sites[site.name()] = site


Loading…
Cancel
Save