how to call pybot from Python in a platform independent way

497 views
Skip to first unread message

Kevin O.

unread,
Jun 30, 2012, 1:57:06 AM6/30/12
to robotframe...@googlegroups.com
Assuming that you have a shell script on the path in *nix and a batch file with the same name in Windows, such as pybot and pybot.bat (assuming you can't use the -m robot.run), is there a way to invoke it that works on *nix and Windows without switching on os.name or anything like that?
Here's what I've tried:
subprocess.call(['pybot','-h'], shell=False) #fails on Win32 b/c its a bat not an exe (WindowsError: [Error 2] The system cannot find the file specified)
subprocess.call(['pybot.bat','-h'], shell=False) #works on windows but fails on Linux for obvious reasons
subprocess.call(['pybot','-h'], shell=True) #works on Windows, but executes on Linux with no arguments passed to pybot

Thanks,
Kevin

Kevin O.

unread,
Jul 2, 2012, 9:04:35 AM7/2/12
to robotframe...@googlegroups.com
Thank you so much Bruce.  Works perfectly.
Reply all
Reply to author
Forward
0 new messages