X-Git-Url: https://code.delx.au/bg-scripts/blobdiff_plain/a8d026613301bb315f8f66f50b1b35d8db996744..b9fbe7ae464bd55ce910929bb678f440c72cb121:/randombg.py diff --git a/randombg.py b/randombg.py index d069b49..a259e1e 100755 --- a/randombg.py +++ b/randombg.py @@ -7,7 +7,12 @@ import asyncore, asynchat, socket import os, os.path, random, sys, time from optparse import OptionParser import logging -logging.basicConfig(format="%(levelname)s: %(message)s") +try: + logging.basicConfig(format="%(levelname)s: %(message)s") +except TypeError: +# Python 2.3's logging.basicConfig does not support parameters + logging.basicConfig() + try: import cPickle as pickle except ImportError: @@ -18,7 +23,7 @@ try: import asyncsched import wallchanger except ImportError, e: - logging.critical("Missing libraries! Exiting...") + logging.critical("Missing libraries! Exiting...", exc_info=1) sys.exit(1) @@ -41,16 +46,16 @@ class BaseFileList(object): def store_cache(self, filename): try: - debug("Attempting to store cache") + logging.debug("Attempting to store cache") fd = open(filename, 'wb') pickle.dump(obj = self, file = fd, protocol = 2) - debug("Cache successfully stored") + logging.debug("Cache successfully stored") except Exception, e: warning("Storing cache: %s" % e) def load_cache(self, filename): try: - debug("Attempting to load cache from: %s" % filename) + logging.debug("Attempting to load cache from: %s" % filename) self.paths.sort() fd = open(filename, 'rb') @@ -69,7 +74,7 @@ class BaseFileList(object): return True except Exception, e: - warning("Loading cache: %s" % e) + logging.warning("Loading cache: %s" % e) return False def scan_paths(self): @@ -147,7 +152,7 @@ class AllRandomFileList(BaseFileList): def store_cache(self, filename): try: fd = open(filename, 'wb') - pickle.dump(obj = self, file = fd, protocol = 2) + pickle.dump(self, fd, 2) logging.debug("Cache successfully stored") except Exception, e: logging.warning("Storing cache", exc_info=1) @@ -240,7 +245,7 @@ class Cycler(object): self.history_filename = options.history_filename logging.debug("Initialising wallchanger") - wallchanger.init(options.background_colour, options.permanent) + wallchanger.init(options.background_colour, options.permanent, options.convert) logging.debug("Initialising file list") if options.all_random: