MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / runCommand

Function runCommand

DemoPrograms/Demo_EXE_Maker.py:63–84  ·  view source on GitHub ↗

run shell command @param cmd: command to execute @param timeout: timeout for command execution @return: (return code from command, command output)

(cmd, timeout=None, window=None)

Source from the content-addressed store, hash-verified

61
62
63def runCommand(cmd, timeout=None, window=None):
64 """ run shell command
65
66 @param cmd: command to execute
67 @param timeout: timeout for command execution
68
69 @return: (return code from command, command output)
70 """
71
72 p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
73 output = ''
74 for line in p.stdout:
75 line = line.decode(errors='replace' if (sys.version_info) < (3, 5)
76 else 'backslashreplace').rstrip()
77 output += line
78 print(line)
79 if window:
80 window.Refresh()
81
82 retval = p.wait(timeout)
83
84 return (retval, output)
85
86
87if __name__ == '__main__':

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected