def main():
    vfs.init()
    try:
        trash = vfs.Trash.get_default()
        mainloop = gobject.MainLoop()
        trash.connect('file-count-changed', on_file_count_changed, mainloop)
        mainloop.run()
    finally:
        vfs.shutdown()
    return 0
def main():
    vfs.init()
    try:
        trash = vfs.Trash.get_default()
        mainloop = gobject.MainLoop()
        trash.connect('file-count-changed', on_file_count_changed, mainloop)
        mainloop.run()
    finally:
        vfs.shutdown()
    return 0
def main(args):
    if len(args) < 2:
        sys.stderr.write('Usage: %s [FILE | DIRECTORY FILE] \n' % args[0])
        return 1
    vfs.init()
    try:
        ml = gobject.MainLoop()
        test = TestFileMonitor(args[1])
        ml.run()
        test.monitor.cancel()
        assert test.monitor.props.cancelled
    finally:
        vfs.shutdown()
    return 0
Example #4
0
def main(args):
    if len(args) < 2:
        sys.stderr.write('Usage: %s [FILE | DIRECTORY FILE] \n' % args[0])
        return 1
    vfs.init()
    try:
        ml = gobject.MainLoop()
        test = TestFileMonitor(args[1])
        ml.run()
        test.monitor.cancel()
        assert test.monitor.props.cancelled
    finally:
        vfs.shutdown()
    return 0
def main():
    gtk.init_check()
    vfs.init()
    test_launch = 'launch' in sys.argv
    try:
        path = tempfile.gettempdir()
        tmp = vfs.File.for_path(path)
        assert tmp.props.parent is not None
        assert tmp.exists()
        assert tmp.props.file_type == vfs.FILE_TYPE_DIRECTORY
        assert (tmp.props.access_flags & vfs.ACCESS_FLAGS_READ) != 0
        assert tmp.is_readable()
        assert (tmp.props.access_flags & vfs.ACCESS_FLAGS_WRITE) != 0
        assert tmp.is_writable()
        print 'URI: %s' % tmp.props.uri
        print 'Path: %s' % tmp.props.path
        print '# of files: %d' % len(tmp.enumerate_children())
        file_path = os.path.join(path,
                                 '%s-lda-test' % tempfile.gettempprefix())
        tmp_file = vfs.File.for_path(file_path)
        assert tmp_file.props.parent is not None and \
               tmp_file.props.parent.props.uri == tmp.props.uri
        tmp_file.replace_contents(CONTENT)
        assert tmp_file.load_contents() == CONTENT
        if test_launch:
            assert tmp_file.launch()
        file_copy_path = '%s-copy' % file_path
        file_copy = vfs.File.for_path(file_copy_path)
        assert tmp_file.copy(file_copy, True)
        assert CONTENT == file_copy.load_contents()
        if not test_launch:
            assert file_copy.remove()
            assert not file_copy.exists()
            assert tmp_file.remove()
            assert not tmp_file.exists()
    finally:
        vfs.shutdown()
Example #6
0
def main():
    gtk.init_check()
    vfs.init()
    test_launch = 'launch' in sys.argv
    try:
        path = tempfile.gettempdir()
        tmp = vfs.File.for_path(path)
        assert tmp.props.parent is not None
        assert tmp.exists()
        assert tmp.props.file_type == vfs.FILE_TYPE_DIRECTORY
        assert (tmp.props.access_flags & vfs.ACCESS_FLAGS_READ) != 0
        assert tmp.is_readable()
        assert (tmp.props.access_flags & vfs.ACCESS_FLAGS_WRITE) != 0
        assert tmp.is_writable()
        print 'URI: %s' % tmp.props.uri
        print 'Path: %s' % tmp.props.path
        print '# of files: %d' % len(tmp.enumerate_children())
        file_path = os.path.join(path,
                                 '%s-lda-test' % tempfile.gettempprefix())
        tmp_file = vfs.File.for_path(file_path)
        assert tmp_file.props.parent is not None and \
               tmp_file.props.parent.props.uri == tmp.props.uri
        tmp_file.replace_contents(CONTENT)
        assert tmp_file.load_contents() == CONTENT
        if test_launch:
            assert tmp_file.launch()
        file_copy_path = '%s-copy' % file_path
        file_copy = vfs.File.for_path(file_copy_path)
        assert tmp_file.copy(file_copy, True)
        assert CONTENT == file_copy.load_contents()
        if not test_launch:
            assert file_copy.remove()
            assert not file_copy.exists()
            assert tmp_file.remove()
            assert not tmp_file.exists()
    finally:
        vfs.shutdown()
Example #7
0
def main(args):
    vfs.init()
    try:
        if len(args) > 1:
            for arg in args[1:]:
                desktop_file = vfs.File.for_path(arg)
                entry = fdo.DesktopEntry.for_file(desktop_file)
                print 'Entry: %s' % entry.props.name
                print 'Entry exec line: %s', entry.get_string('Exec')
                if entry.exists():
                    pid = entry.launch(0, None)
                    print 'PID: %d' % pid
                else:
                    print 'Entry does not exist!'
        else:
            entry = fdo.DesktopEntry.new()
            entry.props.name = 'hosts file'
            entry.props.entry_type = fdo.DESKTOP_ENTRY_TYPE_LINK
            entry.set_string('URL', 'file:///etc/hosts')
            test_filename = '/tmp/desktop-agnostic-test.desktop'
            desktop_file = vfs.File.for_path(test_filename)
            entry.save(desktop_file)
    finally:
        vfs.shutdown()
def main(args):
    vfs.init()
    try:
        if len(args) > 1:
            for arg in args[1:]:
                desktop_file = vfs.File.for_path(arg)
                entry = fdo.DesktopEntry.for_file(desktop_file)
                print 'Entry: %s' % entry.props.name
                print 'Entry exec line: %s', entry.get_string('Exec')
                if entry.exists():
                    pid = entry.launch(0, None)
                    print 'PID: %d' % pid
                else:
                    print 'Entry does not exist!'
        else:
            entry = fdo.DesktopEntry.new()
            entry.props.name = 'hosts file'
            entry.props.entry_type = fdo.DESKTOP_ENTRY_TYPE_LINK
            entry.set_string('URL', 'file:///etc/hosts')
            test_filename = '/tmp/desktop-agnostic-test.desktop'
            desktop_file = vfs.File.for_path(test_filename)
            entry.save(desktop_file)
    finally:
        vfs.shutdown()