def __init__(self):
self.directories = {}
+ def scan_paths(self):
+ pass
+
def add_path(self, path):
debug('Added path "%s" to the list' % path)
for dirpath, dirs, filenames in os.walk(path):
debug('Scanning "%s" for images' % dirpath)
if self.directories.has_key(dirpath):
continue
- filenames = filter_images(filenames)
+ filenames = list(filter_images(filenames))
if len(filenames):
self.directories[dirpath] = filenames
debug('Adding "%s" to "%s"' % (filenames, dirpath))
class Cycler(object):
- def __init__(self, options, paths):
+ def init(self, options, paths):
self.filelist = self.find_files(options, paths)
if not self.filelist.is_empty():
error("No images were found. Exiting...")
def do_server(options, paths):
try:
try:
- cycler = Cycler(options, paths)
+ cycler = Cycler()
listener = Listener(options.socket_filename, cycler)
+ # Initialisation of Cycler delayed so we grab the socket quickly
+ cycler.init(options, paths)
asyncsched.loop()
except KeyboardInterrupt:
print
time.sleep(options.cycle_time)
sock.close()
+def do_oneshot(options, paths):
+ cycler = Cycler()
+ cycler.init(options, paths)
def build_parser():
parser = OptionParser(version="%prog " + VERSION,
parser.add_option("--all-random",
action="store_true", dest="all_random", default=False,
help="Make sure that all images have been displayed before repeating an image")
+ parser.add_option("-1", "--oneshot",
+ action="store_true", dest="oneshot", default=False,
+ help="Set one random image and terminate immediately.")
parser.add_option("--folder-random",
action="store_true", dest="folder_random", default=False,
help="Give each folder an equal chance of having an image selected from it")
if options.verbose == 1:
logging.getLogger().setLevel(logging.INFO)
- print "INFO"
elif options.verbose >= 2:
logging.getLogger().setLevel(logging.DEBUG)
- print "DEBUG"
+
+ if options.oneshot:
+ do_oneshot(options, args)
if os.path.exists(options.socket_filename):
do_client(options, args)