]> code.delx.au - bg-scripts/blobdiff - randombg.py
Merging the two loading function (in an attempt to fix the bugs in loading of cached...
[bg-scripts] / randombg.py
index fff408f3b6d6cacf6fe77487986d5dc1551294b7..00c7d5434eaa0871eacd8106ab0598f1c7c1f431 100755 (executable)
@@ -65,10 +65,11 @@ class BaseFileList(object):
                        if tmp.__class__ != self.__class__:
                                raise ValueError("Using different file list type")
 
-                       self.paths.sort()
-                       if self.paths != getattr(tmp, "paths"):
-                               raise ValueError("Path list changed")
+                       tmp.paths.sort()
+                       if self.paths != tmp.paths:
+                               raise ValueError, "Path list changed"
 
+                       # Overwrite this object with the other
                        for attr, value in tmp.__dict__.items():
                                setattr(self, attr, value)
 
@@ -162,24 +163,6 @@ class AllRandomFileList(BaseFileList):
                except Exception, e:
                        logging.warning("Storing cache", exc_info=1)
 
-       def load_cache(self, filename, rescanPaths = False):
-               logging.debug('Attempting to load cache from "%s"' % filename)
-               self.paths.sort()
-               try:
-                       fd = open(filename, 'rb')
-                       tmp = pickle.load(fd)
-                       if self.paths == tmp.paths:
-                               logging.debug("Path lists match, copying properties")
-                               # Overwrite this object with the other
-                               for attr in ('list', 'imagePointer', 'favourites'):
-                                       setattr(self, attr, getattr(tmp, attr))
-                       else:
-                               logging.debug("Ignoring cache, path lists do not match")
-               except Exception, e:
-                       logging.warning("Loading cache", exc_info=1)
-               else:
-                       return True
-
        def get_current_image(self):
                return self.list[self.imagePointer]
        
@@ -203,6 +186,7 @@ class AllRandomFileList(BaseFileList):
        def is_empty(self):
                return len(self.list) == 0
 
+
 class FolderRandomFileList(BaseFileList):
        """A file list that will pick a file randomly within a directory. Each
        directory has the same chance of being chosen."""
@@ -351,7 +335,6 @@ class Server(asynchat.async_chat):
                        logging.debug('Unknown command received "%s"' % cmd)
 
 
-
 class Listener(asyncore.dispatcher):
        def __init__(self, socket_filename, cycler):
                asyncore.dispatcher.__init__(self)
@@ -462,4 +445,3 @@ def main():
 
 if __name__ == "__main__":
        main()
-