try:
logging.debug("Attempting to store cache")
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:
warning("Storing cache: %s" % e)
class Cycler(object):
- def init(self, options, paths):
+ def init(self, options, paths, oneshot=False):
self.cycle_time = options.cycle_time
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:
sys.exit(1)
self.task = None
- self.cmd_reload()
+ if oneshot:
+ self.cmd_next()
+ else:
+ self.cmd_reload()
def finish(self):
self.filelist.store_cache(self.history_filename)
self.task.cancel()
self.task = asyncsched.schedule(self.cycle_time, next)
logging.debug("Reset timer for %s seconds" % self.cycle_time)
+ self.filelist.store_cache(self.history_filename)
def cmd_reload(self):
image = self.filelist.get_current_image()
def do_oneshot(options, paths):
cycler = Cycler()
- cycler.init(options, paths)
+ cycler.init(options, paths, oneshot=True)
def build_parser():
parser = OptionParser(version="%prog " + VERSION,
if options.oneshot:
do_oneshot(options, args)
-
- if os.path.exists(options.socket_filename):
- do_client(options, args)
else:
- do_server(options, args)
+ if os.path.exists(options.socket_filename):
+ do_client(options, args)
+ else:
+ do_server(options, args)
if __name__ == "__main__":