How to use _start_process method in stestr

Best Python code snippet using stestr_python

terminal.py

Source:terminal.py Github

copy

Full Screen

...29 scroll.setFixedSize(487,300)30 # self.layout = QVBoxLayout()31 # self.layout.addWidget(self.terminal)32 # parentHLayout.addLayout(self.layout)33 self._start_process(34 'xterm',35 ['-into', str(scroll.winId()),36 '-e', 'tmux', 'new-session', '-s', '{0}'.format(self.uuid),'-x','50','-y','50']37 )38 def _start_process(self, prog, args):39 child = QProcess()40 self._processes.append(child)41 child.start(prog, args)42 # self.child.terminate()43 # self.child.waitForFinished()44 def _list_files(self):45 self._start_process(46 'tmux', ['send-keys', '-t', '{0}:0'.format(self.uuid), 'ls', 'Enter'])47 def _terminate_tmux(self):48 # self._start_process(49 # 'tmux', ['send-keys', '-t', '%s:0'%self.uuid, 'exit', 'Enter'])50 for process in self._processes:51 process.terminate()52 def _resize_tmux(self):53 self._start_process(54 'tmux', ['send-keys', '-t', '%s:0'%self.uuid, 'resize-pane -t 0 -R 500', 'Enter'])55 def _switch_to_root(self, password= ROOT_PASSWORD):56 self._start_process(57 'tmux', ['send-keys', '-t', '%s:0'%self.uuid,"sudo su", 'Enter'])58 time.sleep(0.5)59 self._start_process(60 'tmux', ['send-keys', '-t', '%s:0'%self.uuid, str(password) , 'Enter'])61 def runCommand(self,command, password_prompt_req_flag=False):62 if password_prompt_req_flag: # if expecting sudo in command and already not a sudoer63 self._start_process(64 'tmux', ['send-keys', '-t', '%s:0'%self.uuid, '%s'%command, 'Enter'])65 time.sleep(1)66 self._start_process(67 'tmux', ['send-keys', '-t', '%s:0'%self.uuid, str(ROOT_PASSWORD) , 'Enter'])68 else:69 self._start_process(70 'tmux', ['send-keys', '-t', '%s:0'%self.uuid, '%s'%command, 'Enter'])71 self._start_process(72 'tmux', ['capture-pane', '-t', '%s:0'%self.uuid])73 #stdout, stderr = process.communicate()74 # tmux capture-pane -pS -3276875 #print Popen(['tmux', 'capture-pane','-pS','-32768'], stdout=PIPE).communicate()[1]76 # tmux help, See link below77 # http://unix.stackexchange.com/questions/125647/get-tmux-scroll-buffer-contents78 QtCore.QTimer.singleShot(3000, lambda: self._callback_tmux())79 def _callback_tmux(self):80 stderr = _sudo_exec("tmux capture-pane -pS -32768 -t {0}".format(self.uuid), ROOT_PASSWORD)81 msg =""82 try:83 idx = stderr.rindex("SUMMARY")84 msg = stderr[idx-5:-65]85 except:...

Full Screen

Full Screen

process.py

Source:process.py Github

copy

Full Screen

...10 self._hook_before_exploit = None11 self._process = None12 self._byarg = False13 context.log_level = "error"14 def _start_process(self, cmd=""):15 raise NotImplementedError("")16 def send(self, cmd=""):17 if self._byarg:18 self._start_process(cmd)19 else:20 self._process.send(cmd)21 return self22 def recv(self, number=4096):23 context.log_level = "error"24 if self._process is not None:25 res = self._process.recv(number)26 if self._byarg:27 self._process.shutdown("recv")28 self._process.shutdown("send")29 self._process.close()30 context.log_level = self._verbosity31 return res32 else:33 context.log_level = self._verbosity34 return ""35 def reconnect(self):36 context.log_level = "error"37 if self._hook_before_begin is not None:38 self._hook_before_begin(self)39 return self40 def hook_before_begin(self, hook):41 self._hook_before_begin = hook42 hook(self)43 return self44 def hook_before_exploit(self, hook=None, register=False):45 if register is False:46 self._hook_before_exploit(self)47 else:48 self._hook_before_exploit = hook49 return self50 def interactive(self):51 self._process.interactive()52class SshProcess(Process):53 def __init__(self, host, port, user, password, target,54 cmd="", byarg=False, verbosity='info'):55 Process.__init__(self, verbosity)56 context.log_level = "error"57 self._ssh = ssh(user, host, port, password)58 self._target = target59 if cmd != "":60 self._cmd = cmd.split(" ")61 else:62 self._cmd = []63 self._byarg = byarg64 if self._byarg is False:65 self._start_process()66 def _start_process(self, cmd=""):67 argv = [self._target]68 argv += self._cmd69 argv.append(cmd)70 self._process = self._ssh.process(argv)71 if self._hook_before_begin is not None:72 self._hook_before_begin(self)73 return self74class LocalProcess(Process):75 def __init__(self, target, cmd="", byarg=False, verbosity='info'):76 Process.__init__(self, verbosity)77 self._target = target78 self._process = None79 if cmd != "":80 self._cmd = cmd.split(" ")81 else:82 self._cmd = []83 self._byarg = byarg84 if self._byarg:85 self._start_process()86 self._verbosity = verbosity87 self._hook_before_begin = None88 self._hook_before_exploit = None89 def _start_process(self, cmd=""):90 argv = [self._target]91 argv += self._cmd92 argv.append(cmd)93 self._process = process(argv)94 if self._hook_before_begin is not None:95 self._hook_before_begin(self)96 return self97class RemoteProcess(Process):98 def __init__(self, host, port, verbosity='info'):99 Process.__init__(self, verbosity)100 self._host = host101 self._port = port102 self._process = None103 self._verbosity = verbosity104 self._start_process()105 self._hook_before_begin = None106 self._hook_before_exploit = None107 def _start_process(self, cmd=""):108 self._process = remote(self._host, self._port)109 context.log_level = self._verbosity110 return self111 def send(self, cmd=""):112 self._process.send(cmd)113 return self114 def reconnect(self):115 context.log_level = "error"116 self._start_process()117 if self._hook_before_begin is not None:118 self._hook_before_begin(self)119 context.log_level = self._verbosity...

Full Screen

Full Screen

terminal01.py

Source:terminal01.py Github

copy

Full Screen

...16 self.resize(600, 600)17 layout= QVBoxLayout(self)18 self.terminal1 = QWidget(self)19 layout.addWidget(self.terminal1)20 self._start_process(21 #'xterm',22 #['-into', str(self.terminal1.winId()),23 'urxvt',24 ['-embed', str(self.terminal1.winId()),25 '-e', 'tmux', 'new', '-s', self.pid+'-session1'])26 self.terminal2 = QWidget(self)27 layout.addWidget(self.terminal2)28 self._start_process(29 #'xterm',30 #['-into', str(self.terminal2.winId()),31 'urxvt',32 ['-embed', str(self.terminal2.winId()),33 '-e', 'tmux', 'new', '-s', self.pid+'-session2'])34 button = QPushButton('List files')35 layout.addWidget(button)36 button.clicked.connect(self._list_files)37 button2 = QPushButton('Exit')38 layout.addWidget(button2)39 button2.clicked.connect(self._exit)40 #def __del__(self):41 #self._start_process(42 #'tmux', ['send-keys', '-t', 'session1:0', 'exit', 'Enter'])43 def _start_process(self, prog, args):44 child = QProcess()45 self._processes.append(child)46 child.start(prog, args)47 def _list_files(self):48 self._start_process(49 'tmux', ['send-keys', '-t', self.pid+'-session1:0', 'ls', 'Enter'])50 self._start_process(51 'tmux', ['send-keys', '-t', self.pid+'-session2:0', 'ls /', 'Enter'])52 def _exit(self):53 self._start_process(54 'tmux', ['send-keys', '-t', self.pid+'-session1:0', 'exit', 'Enter'])55 self._start_process(56 'tmux', ['send-keys', '-t', self.pid+'-session2:0', 'exit', 'Enter'])57if __name__ == "__main__":58 app = QApplication(sys.argv)59 main = embeddedTerminal()60 main.show()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stestr automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful