python script doesn't work when testcomplete launches from command line
- 9 years ago
Sample script:
from subprocess import * def main(): p = Popen("notepad.exe", stdout=PIPE, shell=True)
TestComplete is GUI app and does not have its own console. Omitting stdin and stderr parameters in Popen constructor cause errors in some cases, because code in Lib\subprocess.py tries to use console of current process (TestComplete.exe).
Use not None stdin and stderr values. If it is suitable for you, it could be DEVNULL, PIPE, file...
stdin, stdout and stderr specify the executed program’s standard input, standard output and standard error file handles, respectively. Valid values are PIPE, DEVNULL, an existing file descriptor (a positive integer), an existing file object, and None. PIPE indicates that a new pipe to the child should be created. DEVNULL indicates that the special file os.devnull will be used. With the default settings of None, no redirection will occur; the child’s file handles will be inherited from the parent. Additionally, stderr can be STDOUT, which indicates that the stderr data from the applications should be captured into the same file handle as for stdout.
from subprocess import * def main(): p = Popen("notepad.exe", stdout=PIPE, stdin=PIPE, stderr=PIPE, shell=True)