Check that the given executable is to be found in %PATH%
Get the full path of an executable by looking at PATH environment variable (and PATHEXT on windows)
Returns: | None if program was not found, the full path to executable otherwize |
---|
Execute a command line.
Note: first arg of the cmd is assumed to be something inside %PATH%. (or in env[PATH] if env is not None)
Note: the shell= argument of the subprocess.Popen call will always be False.
When using call(cmd, ...), check_is_in_path() is always call with cmd[0] as argument, then replaced with the result of find_program().
This way, on Windows:
qisys.command.call(["cmake", ...])
works as soon as cmake.exe is in PATH
subprocess.Popen is always called with shell=False, for security reasons.
Unless explicitly told not to, CommandFailedException is raised when the return code of the command is not zero.
To be used in a “with” statement:
with call_background(...):
do_stuff()
do_other_stuff()
Process is run in the background, then do_stuff() is called.
By the time you are executing do_other_stuff(), you know that the process has been killed, better yet, if an exception has occurred during do_stuff, this exception is re-raised after the process has been killed.
A simple way to run commands.
Command will be started by run according to timeout parameter (not specified == no timeout). If it firstly send a SIGTERM signal to the process and wait 5 seconds for it to terminate alone (timeout). If it doesn’t stop by itself, it will kill the group of process (created with subprocess) to exterminate it. Process is then considered to be a zombie.