subprocess and gvfs-mount

Adam Tauno Williams awilliam at whitemice.org
Tue May 18 08:12:59 EDT 2010


On Mon, 2010-05-17 at 17:54 +0200, Samuel Bancal wrote:
> Hi,
> I'm coding a script that does some automates for my users ...
> including mounting a smb share.
> Because we are using Gnome, I choosed to use gvfs-mount, which is
> quite similar to "Places > Connect to Server > ..."=
> Now my script does :
>         print "*** Mounting the FILER ..."
>         cmd = "/usr/bin/gvfs-mount smb://%s\;%
> s at myfiler.domain.ch/data/%s" % (my_domain, my_user_name, my_user_name)
>         try:
>             retCode = subprocess.call(cmd, shell=True)
>         except KeyboardInterrupt, e:
>             sys.stderr.write("Interrupted by ctrl-c. Exiting\n")
>             sys.exit(1)
>         if retCode != 0:
>             sys.stderr.write("Error while mounting : %s\n" % retCode
> I have two major problems with this code :
> - In case of "ctr-c" while the password is asked to the user, I get a
> Terminal in which the output from keyboard is inhibited... (like while
> typing password)
> - When the user runs this script by "double-click > Run" (not "Run in
> terminal") ... there is no interaction with the user.

Which is normal [there is a run-in-terminal check box somewhere?].  If
your users are running it in GNOME then you should implement a GUI
(PyGTK) for the user interaction [prompting for the password].  Or
better use the GNOME keyring.

<http://pypi.python.org/pypi/keyring>

-- 
Adam Tauno Williams <awilliam at whitemice.org> LPIC-1, Novell CLA
<http://www.whitemiceconsulting.com>
OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba




More information about the Python-list mailing list