Mounting a path with GVFS

View: New views
1 Messages — Rating Filter:   Alert me  

Mounting a path with GVFS

by Aldrin Martoq :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to mount a remote FTP folder using GVFS, just for "testing"
purposes.

My problem is that I need to change the name of the folder, because:
- I don't want in nautilus the label "ftp as amartoq on 127.0.0.1:2121"
for ex (I may set the user randomly for example).
- I  want to mount and treat different folders as independent mounts
(say /tmp and /home). So, I want it to say for ex: "HOME on 127.0.0.1
(ftp)" AND "TMP on 127.0.0.1 (ftp)".
- I would like to change the icon ;)


So, I tried gvfs-mount but no luck in changing the mounted folder name.



After a while, I created a "simple" python-dbus client (attached), which
actually works mostly the same as the gvfs-mount program. But it seems
the client cannot set/change the mount name.




Q1. Is there any way to change the label name?

Q2. What about connecting through FTP with the same user, host and
port?? The only parameter I can change in DBUS is something that looks
like a path, but gvfs answer:
"org.glib.GError.g_2Dio_2Derror_2Dquark.c17: Location is already
mounted" if I repeat the command giving another sys.arg[1] for
mountLocation().



Thanks!



--
Aldrin Martoq <amartoq@...>
http://aldrinvideopodcast.podshow.com/


[mount-dbus.py]

#!/usr/bin/env python
# mount-gvfs.py - /Attempt/ of Mounting a folder using GVFS through DBus
# Copyright (C) 2008 Aldrin Martoq <amartoq@...>
# Licensed under GPL v2

try:
        import rlcompleter
        import readline
        readline.parse_and_bind("tab: complete")
except Exception:
        pass


import dbus, dbus.glib, gobject, dbus.service, sys
from pprint import pprint

class AskPass(dbus.service.Object):
        @dbus.service.method('org.gtk.vfs.MountOperation',
                        in_signature='sssu', out_signature='bbsssbu')
        def askPassword(self, s1, s2, s3, u1):
                for arg in [s1, s2, s3, u1]:
                        print "askPass: " + str(arg)

                print "-------- Please TYPE (NOTE: PASSWORD WILL NOT BE HIDDEN) ---------------"
               
                username = raw_input("Username: ")
                password = raw_input("Password: ")

                print "Trying: " + username + " - " + password
                return [True, False, password, username, "", False, 0]



def name_owner_changed(*args, **kwargs):
        print ("Signal: " + kwargs['dbus_interface'] + "->" + kwargs['member'])
        for arg in args:
                print "Signal:  " + str(arg)
        print "Signal DONE."
        if kwargs['member'] == "NameAcquired":
                myname = str(arg)
                args = [tuple(["host", dbus.Array('127.0.0.1', 'y')]), tuple(["port", '2121']), tuple(["type", 'ftp'])]
                try:
                        path = sys.argv[1] or '/'
                except:
                        path = '/'
                print "INVOKING mountLocation with path[" + path + "] name[" + myname + "] args:[" + str(args) + "]"
                server.mountLocation(tuple([dbus.Array(path, 'y'), args]), myname, dbus.ObjectPath("/org/gtk/gvfs/mountop/0"), reply_handler=mount_reply, error_handler=mount_reply_error)



def mount_reply(*args, **kwargs):
        print "Mount Reply: ",
        pprint(kwargs)
        for arg in args:
                print "Mount Reply:  " + str(arg)
        loop.quit()
       


def mount_reply_error(*args, **kwargs):
        print "Mount Reply Error: ",
        pprint(kwargs)
        for arg in args:
                print "Mount Reply Error:  " + str(arg)
        loop.quit()



if __name__ == "__main__":
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        bus = dbus.SessionBus()

        try:
                name = dbus.service.BusName("org.gtk.vfs.Daemon", bus)
                askpass = AskPass(bus, '/org/gtk/gvfs/mountop/0')

                proxy = bus.get_object('org.gtk.vfs.Daemon', '/org/gtk/vfs/mounttracker')
                server = dbus.Interface(proxy, 'org.gtk.vfs.MountTracker')
        except dbus.DBusException:
                traceback.print_exc()
                sys.exit(1)

        bus.add_signal_receiver(name_owner_changed, interface_keyword='dbus_interface', member_keyword='member')

        loop = gobject.MainLoop()
        loop.run()



_______________________________________________
gnome-vfs-list mailing list
gnome-vfs-list@...
http://mail.gnome.org/mailman/listinfo/gnome-vfs-list