Calling subprocess with arguments

Tyler Laing trinioler at gmail.com
Fri Jun 19 11:28:17 EDT 2009


Thanks mike, the idea that maybe some of the info isn't being passed is
certainly interesting.

Here's the output of os.environ and sys.argv:

tyler at Surak:~$ cat environ
{'XAUTHORITY': '/home/tyler/.Xauthority', 'GNOME_DESKTOP_SESSION_ID':
'this-is-deprecated', 'ORBIT_SOCKETDIR': '/tmp/orbit-tyler', 'LESSOPEN': '|
/usr/bin/lesspipe %s', 'LOGNAME': 'tyler', 'USER': 'tyler', 'PATH':
'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
'HOME': '/home/tyler', 'WINDOWPATH': '7', 'SSH_AGENT_PID': '3235', 'LANG':
'en_CA.UTF-8', 'TERM': 'xterm', 'SHELL': '/bin/bash', 'XDG_SESSION_COOKIE':
'c40b96e13a53e01daf91b3c24a37cc3f-1245418411.623618-1455422513',
'SESSION_MANAGER': 'local/Surak:/tmp/.ICE-unix/3078', 'SHLVL': '1',
'DISPLAY': ':0.0', 'WINDOWID': '62914615', 'COLUMNS': '80',
'GPG_AGENT_INFO': '/tmp/seahorse-WkObD8/S.gpg-agent:3260:1', 'USERNAME':
'tyler', 'GDM_XSERVER_LOCATION': 'local', 'GTK_RC_FILES':
'/etc/gtk/gtkrc:/home/tyler/.gtkrc-1.2-gnome2', 'LINES': '24',
'SSH_AUTH_SOCK': '/tmp/keyring-glzV2L/socket.ssh', 'DESKTOP_SESSION':
'default', 'GDMSESSION': 'default', 'DBUS_SESSION_BUS_ADDRESS':
'unix:abstract=/tmp/dbus-HXzG5Pt75p,guid=9fc00f8a914d6f800340ca634a3b93ac',
'_': '/usr/bin/python', 'GTK_MODULES': 'canberra-gtk-module',
'GNOME_KEYRING_SOCKET': '/tmp/keyring-glzV2L/socket', 'LESSCLOSE':
'/usr/bin/lesspipe %s %s', 'GNOME_KEYRING_PID': '3065', '__GL_YIELD':
'NOTHING', 'GDM_LANG': 'en_CA.UTF-8', 'HISTCONTROL': 'ignoreboth',
'XDG_DATA_DIRS': '/usr/local/share/:/usr/share/:/usr/share/gdm/', 'PWD':
'/home/tyler', 'COLORTERM': 'gnome-terminal', 'FROM_WRAPPER': 'yes',
'LS_COLORS':
'no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:'}
tyler at Surak:~$ cat argv
['./testsub.py', '-I', 'rc']

On Fri, Jun 19, 2009 at 8:21 AM, Mike Kazantsev <mk.fraggod at gmail.com>wrote:

> On Fri, 19 Jun 2009 08:07:29 -0700
> Tyler Laing <trinioler at gmail.com> wrote:
>
> > I can't use communicate, as it waits for the child process to terminate.
> > Basically it blocks. I'm trying to have dynamic communication between the
> > python program, and vlc.
>
> Unfortunately, subprocess module doesn't allow it out-of-the-box, but
> you can use fnctl calls to perform non-blocking reads/writes on it's
> pipes, like this:
>
>  flags = fcntl.fcntl(fd, fcntl.F_GETFL)
>  fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
>
> After that, you can grab all the available data from the pipe at any
> given time w/o blocking.
>
> Try this recipe:
>
>  http://code.activestate.com/recipes/576759/
>
> --
> Mike Kazantsev // fraggod.net
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>


-- 
Visit my blog at http://oddco.ca/zeroth/zblog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090619/fd3b45bf/attachment.html>


More information about the Python-list mailing list