test_popen

harrismh777 harrismh777 at charter.net
Thu Jun 9 01:04:32 EDT 2011


Looks like my 2.7 test_popen failure is an open issue7671... since Jan 
2010. Looks like it really does function ok.

At any rate, I was able to test Popen myself today, and it ran fine. I 
needed to write a script that will disable the touch pad on this HP g 
series, because there is no way to do that in the bios. So, in 
gnu/linux, you get the device id list with 'xinput list' and then to 
disable the touch pad for that id, enter this command:

   'xinput set-prop <id#> "Device Enabled" 0'

So, I'm using Popen class to talk to the system through a shell and read 
back the stdout through a pipe, and was able to retrieve the device ids 
with this (in ver 2.7.1) :

from subprocess import PIPE, Popen
cmd = 'xinput list'
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
print stdout

(actually I parsed it with the re module)

    The only difference here between 2.7 and 3.2 is that 3.2 gives back 
a b'string' ... otherwise, same same.

    I'm parsing the ids listing with the re module and then using Popen 
to issue the command to disable the touch pad. Its a little more 
complicated than that, because I only allow the script to 'work' if it 
finds the id=# for an attached mouse or track-ball... I use the Logitech 
Trackman... otherwise it asks the double question for whether the touch 
pad should be deactivated. So, clicking the icon once disables the pad, 
and clicking it again re-enables it, assuming the trackman is plugged 
in. The trick does not work across login-logout, so the touchpad must be 
disabled in the startup, or else manually every time the user logs in.

    When I get the silly thing done I'll post it, in case anyone else is 
interested... there does seem to be a lot of interest on the net for 
disabling the synaptics touch pad... it just gets in the way most of the 
time and isn't very efficient the rest of the time. (but I digress)


kind regards,
m harris







More information about the Python-list mailing list