Exemplo n.º 1
0
 def _dnd_data_get(self, wid, context, x, y, selection, targetType, time):
     for uri in selection.get_uris():
         try:
             log.debug("Drag recieved %s" % uri)
             if Vfs.uri_is_folder(uri):
                 self._add_folder(uri)
             else:
                 self._add_file(uri)
         except Exception, err:
             log.debug("Error adding %s\n%s" % (uri,err))
Exemplo n.º 2
0
    ok("--- TESTING VFS WITH FILE IMPL: %s" % impl, True)
    #print Vfs.FolderScanner

    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 = Vfs.FolderScannerThreadManager(maxConcurrentThreads=1)

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

    t1 = stm.make_thread("file:///tmp", False, False, prog, done)
    t2 = stm.make_thread("file://"+tmpdiruri, False, False, prog, done)
    stm.join_all_threads()