def spawnSshShell(self, host, command): """ Spawns an interactive ssh shell on the host @param host Remote host to connect to, if none jump-host will be used @param command Command to execute on remote shell @return Return code of the spawned ssh shell process """ proc = subprocess.Popen( self.__sshPath.format( "{}".format("-p " + self.__port if self.__port else ""), self.__username, self.__host if not host else host, "{}".format(command if command else ""), ), stdout=sys.stdout, stderr=sys.stderr, shell=True, ) # Start the process reader threads (for stdout and stderr) proc_reader = utils.ProcReader(proc, sys.stdout, sys.stderr) # Block here until we exit from the process proc_reader.wait() return proc.returncode
def pr_none(): import subprocess command = 'ls' if sys.platform.startswith('win'): command = 'dir' proc = subprocess.Popen([command], shell=True) pr = cu.ProcReader(proc, None, None) return pr
def pr_none(): import subprocess # Start a long running process so we have time to run tests on it before it finishes # Put the new process into a separate group so its signal are isolated from ours kwargs = dict() if sys.platform.startswith('win'): command = 'timeout -t 5 /nobreak' kwargs['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP else: command = 'sleep 5' kwargs['start_new_session'] = True proc = subprocess.Popen(command, shell=True, **kwargs) pr = cu.ProcReader(proc, None, None) return pr
def pr_none(): import subprocess # Start a long running process so we have time to run tests on it before it finishes # Put the new process into a separate group so signals sent to it won't interfere with this process if sys.platform.startswith('win'): command = 'timeout -t 5 /nobreak' creationflags = subprocess.CREATE_NEW_PROCESS_GROUP start_new_session = False else: command = 'sleep 5' creationflags = 0 start_new_session = True proc = subprocess.Popen(command, creationflags=creationflags, start_new_session=start_new_session, shell=True) pr = cu.ProcReader(proc, None, None) return pr