Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106461
| From | Wildman <best_lay@yahoo.com> |
|---|---|
| Subject | Request Help With Function |
| Newsgroups | comp.lang.python |
| Organization | Wildman Productions |
| Message-ID | <-JSdnXtfvv0oXp_KnZ2dnUU7-evNnZ2d@giganews.com> (permalink) |
| Date | 2016-04-04 14:42 -0500 |
I am working on a Linux gui program where I want to be able
to click a Help button and open a man page using a viewer.
I wrote a search function that can be called several times,
if needed, with different arguments. I wrote a test program
that tries to open the Bash man page in a terminal and will
display a message box if the search fails. It passes the
system path, terminal emulators and command line arguments
to the search function. I appears that you can't pass a list
to a function so I am passing the arguments as strings and then
converting them to lists for parsing in the search function.
When I run the test program, I get this error:
Traceback (most recent call last):
File "./man.py", line 38, in <module>
launch_help()
File "./man.py", line 10, in launch_help
if search(pathlist, executelist, commandlist):
File "./man.py", line 27, in search
subprocess.Popen(command)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
TypeError: execv() arg 2 must contain only strings
I have not been able to figure out why I'm getting the error.
Any help would be appreciated. Below is the complete code for
the test program:
#!/usr/bin/env python
import os, subprocess, tkMessageBox
def launch_help():
pathlist = os.environ["PATH"]
executelist = "xvt,xfce4-terminal"
commandlist = "-e,man bash"
if search(pathlist, executelist, commandlist):
return None
message = "Open a terminal and enter: man bash"
tkMessageBox.showinfo("Help", message)
def search(pathlist, executelist, commandlist):
pathlist = pathlist.split(":")
executelist = executelist.split(",")
commandlist = commandlist.split(",")
done = False
for path in pathlist:
for execute in executelist:
target = path + "/" + execute
if os.path.isfile(target):
done = True
command = [target, commandlist]
subprocess.Popen(command)
if done:
break
if done:
break
if done:
return True
else:
return False
launch_help()
--
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Request Help With Function Wildman <best_lay@yahoo.com> - 2016-04-04 14:42 -0500
Re: Request Help With Function Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-04 13:54 -0600
Re: Request Help With Function Wildman <best_lay@yahoo.com> - 2016-04-04 19:26 -0500
Re: Request Help With Function MRAB <python@mrabarnett.plus.com> - 2016-04-04 21:02 +0100
Re: Request Help With Function Wildman <best_lay@yahoo.com> - 2016-04-04 19:38 -0500
csiph-web