* TypeError - Need help passings args
Ernesto
erniedude at gmail.com
Wed Nov 2 10:07:24 EST 2005
My program is below. I'm trying to use two Windows ".exe" files with
my command line python interface. I get user input, then call
"launchWithoutConsole". This was working OK until I introduced the
'args' part. Now I get the following error everytime I call
"launchWithoutConsole":
return subprocess.Popen([command] + args,
startupinfo=startupinfo).wait()
TypeError: can only concatenate list (not "str") to list
I'm not sure if it's the WAY I'm passing it or if it's the function
itself (which I retrieved from
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/409002
)
Please help. Thanks!
import subprocess
def launchWithoutConsole(command, args):
"""Launches 'command' windowless and waits until finished"""
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
return subprocess.Popen([command] + args,
startupinfo=startupinfo).wait()
infinity = 1
#Get user input in iterative loop
while infinity:
userCommand = raw_input("> ")
if userCommand == "connect":
launchWithoutConsole("devcon.exe",'enable
"@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000')
launchWithoutConsole("devcon.exe",'enable
"@USB\VID_0403&PID_6010&MI_01\7&15E4F68&1&0001')
elif userCommand == "disconnect":
launchWithoutConsole("devcon.exe",'disable
"@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000')
launchWithoutConsole("devcon.exe",'disable
"@USB\VID_0403&PID_6010&MI_01\7&15E4F68&1&0001')
else:
# include full path to rib.exe in quotes.
launchWithoutConsole("rib.exe", userCommand)
More information about the Python-list
mailing list