def get_all(self):
     DataProvider.DataSource.get_all(self)
     photos = []
     for album in self.albums:
         if album[FILENAME_IDX] in self.enabledAlbums:
             for photouri in album[PHOTOS_IDX]:
                 if Vfs.uri_exists(photouri):
                     photos.append(photouri)
     return photos
 def get_all(self):
     DataProvider.DataSource.get_all(self)
     photos = []
     for album in self.albums:
         if album[FILENAME_IDX] in self.enabledAlbums:
             for photouri in album[PHOTOS_IDX]:
                 if Vfs.uri_exists(photouri):
                     photos.append(photouri)
     return photos
Exemple #3
0
def read_removable_volume_group_file(folderUri):
    items = []
    f = File.File(URI=folderUri)
    if f.is_on_removale_volume():
        #read from the /volume/root/.conduit file
        rooturi, path = get_removable_volume_info(f)
        if rooturi and path:
            conf = ConfigParser.SafeConfigParser()
            conf.read(path)
            for p, n in conf.items("DEFAULT"):
                log.debug("Read group (%s = %s)" % (p, n))
                #check the path still exists on the volume
                if Vfs.uri_exists(rooturi + p):
                    items.append((p, n))
    return items
Exemple #4
0
def read_removable_volume_group_file(folderUri):
    items = []
    f = File.File(URI=folderUri)
    if f.is_on_removale_volume():
        #read from the /volume/root/.conduit file
        rooturi,path = get_removable_volume_info(f)
        if rooturi and path:
            conf = ConfigParser.SafeConfigParser()
            conf.read(path)
            for p,n in conf.items("DEFAULT"):
                log.debug("Read group (%s = %s)" % (p,n))
                #check the path still exists on the volume
                if Vfs.uri_exists(rooturi+p):
                    items.append((p,n))
    return items
Exemple #5
0
 def do_image_dataprovider_tests(self, supportsGet, supportsDelete, safePhotoLUID, ext="png"):
     """
     Tests get(), put(), delete() and Image dataprovider specific
     functions
     """
     #Test get() and image specific friends
     if supportsGet:
         try:
             info = self.sink.module._get_photo_info(safePhotoLUID)
             ok("Got photo info", info != None)
             url = self.sink.module._get_raw_photo_url(info)
             ok("Got photo url (%s)" % url, url != None and Vfs.uri_exists(str(url)))
         except Exception, err:
             traceback.print_exc()
             ok("Got photo info/url (%s)" % err, False)
Exemple #6
0
import conduit.vfs.File as VfsFile
import conduit.utils as Utils

ok("--- TESTING VFS WITH FILE IMPL: %s" % Vfs.backend_name(), True)
ok("Supports remote uri schemes: %s" % Vfs.backend_supports_remote_uri_schemes(), True)

safe = '/&=:@'
unsafe = ' !<>#%()[]{}'
safeunsafe = '%20%21%3C%3E%23%25%28%29%5B%5D%7B%7D'

ok("Dont escape path characters",Vfs.uri_escape(safe+unsafe) == safe+safeunsafe)
ok("Unescape back to original",Vfs.uri_unescape(safe+safeunsafe) == safe+unsafe)
ok("Get protocol", Vfs.uri_get_protocol("file:///foo/bar") == "file://")
name, ext = Vfs.uri_get_filename_and_extension("file:///foo/bar.ext")
ok("Get filename (%s,%s)" % (name,ext), name == "bar" and ext == ".ext")
ok("file:///home exists", Vfs.uri_exists("file:///home") == True)
ok("/home exists", Vfs.uri_exists("/home") == True)
ok("/home is folder", Vfs.uri_is_folder("/home") == True)
ok("/foo/bar does not exist", Vfs.uri_exists("/foo/bar") == False)
ok("format uri", Vfs.uri_format_for_display("file:///foo") == "/foo")

tmpdiruri = Utils.new_tempdir()

# Test the folder scanner theading stuff
fileuri = Utils.new_tempfile("bla").get_local_uri()
stm = VfsFile.FolderScannerThreadManager(maxConcurrentThreads=1)

def prog(*args): pass
def done(*args): pass

t1 = stm.make_thread("file:///tmp", False, False, prog, done)
Exemple #7
0
 def is_configured(self, isSource, isTwoWay):
     return self.folder and Vfs.uri_exists(self.folder)
Exemple #8
0
old_hash = temp.get_hash()

# now, add some more
tempsize = random.randint(100, 200)
contents += "b" * tempsize
temp.set_contents_as_text(contents)
ok("Base: Check if appending to a file changes its hash", temp.get_hash() != old_hash)

# reset the mtime, and make sure the hash is still different
temp.set_mtime(old_mtime)
ok("Base: Check if reseting a file's mtime is successful", temp.get_mtime() == old_mtime)
ok("Base: Check that the hash is still different, even with the same mtime.", temp.get_hash() != old_hash)

remUri = get_external_resources("folder")["removable-volume"]
rf = File.File(remUri)
if Vfs.uri_exists(remUri):
    ok("Base: Removable volume detected", rf.is_on_removale_volume() == True)
    ok("Base: Removable volume calculate root path", rf.get_removable_volume_root_uri() == remUri)

folder = File.File(os.environ["HOME"])
ok("Base: check if HOME exists", folder.exists() == True)
ok("Base: check if HOME is folder", folder.is_directory() == True)

localURIs = [
    os.path.abspath(os.path.join(my_path, "..", "test-data", "oldest")),
    os.path.abspath(os.path.join(my_path, "..", "test-data", "older")),
    os.path.abspath(os.path.join(my_path, "..", "test-data", "newer")),
    os.path.abspath(os.path.join(my_path, "..", "test-data", "newest")),
]

# test the comparison of files by mtime
Exemple #9
0
 def is_configured(self, isSource, isTwoWay):
     return self.folder and Vfs.uri_exists(self.folder)