def thread_work(client_exe_path, msg): # create a process to execute the client_exe # TODO: add execute timeout _cmd = '%s %s' % (client_exe_path, msg) cmd = WrapCommand(_cmd) cmd.start() logger.debug('Start command start %s' % _cmd) cmd.join() logger.debug('Start command end %s' % _cmd) return cmd
def run_now(self, commands): """ Command run method :param commands: All command list :return: None """ for command in commands: command_obj = WrapCommand(command, shell=True) command_obj.start() command_obj.join() if command_obj.returncode != 0: self.__log_object.log_error_now(command, command_obj.results) else: self.__log_object.log_output(command, command_obj.results)
def execute_adb_cmd(cmd='adb devices'): ''' execute adb command return a tuple (stdoutdata, stderrdata) ''' idx = cmd.find('adb') if idx == -1: print 'must contain adb in cmd' return False, False cmd = cmd[idx + 3:] print ADB, cmd cmd2 = WrapCommand('%s %s' % (ADB, cmd)) cmd2.start() cmd2.join() return cmd2.results
def execute_adb_cmd(cmd='adb devices'): ''' execute adb command return a tuple (stdoutdata, stderrdata) ''' idx=cmd.find('adb') if idx == -1: print 'must contain adb in cmd' return False,False cmd=cmd[idx+3 :] print ADB,cmd cmd2=WrapCommand('%s %s' % (ADB,cmd)) cmd2.start() cmd2.join() return cmd2.results
def connect_and_check(): '''check adb devices connect or not''' adb = WrapCommand('%s devices' % ADB, shell=True) adb.start() i = 5 while i > 0 and adb.is_alive(): i -= 1 time.sleep(1) if adb.is_alive(): adb.stop() print 'adb111' adb.join() print adb.results for line in adb.results[0].split(os.linesep): if line.endswith("device") or line.endswith("recovery"): return True return False
def connect_and_check(): '''check adb devices connect or not''' adb = WrapCommand('%s devices' % ADB,shell=True) adb.start() i = 5 while i > 0 and adb.is_alive(): i -= 1 time.sleep(1) if adb.is_alive(): adb.stop() print 'adb111' adb.join() print adb.results for line in adb.results[0].split(os.linesep): if line.endswith("device") or line.endswith("recovery"): return True return False
def adb_kill_server(): ''' adb kill-server''' cmd = WrapCommand('%s kill-server' % ADB, shell=True) cmd.start() cmd.join()
#!/usr/bin/env python from commandwrapper import WrapCommand # ls -l | grep and | wc -l if 1: Ls = WrapCommand('ls -l') GrepAnd = WrapCommand('grep and') Wc = WrapCommand('wc -l') Wc.stdin = GrepAnd GrepAnd.stdin = Ls Wc.start() Wc.join() print Wc.results # ls -l | grep and | wc -l if 1: Ls = WrapCommand('ls -l | grep and | wc -l', shell=True) Ls.start() Ls.join() print Ls.results
#!/usr/bin/env python from commandwrapper import WrapCommand # ls -l | grep and | wc -l if 1: Ls = WrapCommand( 'ls -l') GrepAnd = WrapCommand( 'grep and') Wc = WrapCommand( 'wc -l') Wc.stdin = GrepAnd GrepAnd.stdin = Ls Wc.start() Wc.join() print Wc.results # ls -l | grep and | wc -l if 1: Ls = WrapCommand( 'ls -l | grep and | wc -l', shell=True) Ls.start() Ls.join() print Ls.results
def adb_kill_server(): ''' adb kill-server''' cmd=WrapCommand('%s kill-server' % ADB,shell=True) cmd.start() cmd.join()
else: # check whether there is a new git or a removed git first. new_git, removed_git = check_repo_change(opts.manifest1, p_r_map) if new_git: print '!Warning : there have some new git bewteen two repo\n\t%s' % new_git if removed_git: print '!Warning : there have some removed git bewteen two repo\n\t%s' % removed_git doc1 = parse(opts.manifest1) for el in doc1.getElementsByTagName('project'): if el.getAttribute('path'): if p_r_map.has_key(el.getAttribute('path')): p_r_map[el.getAttribute('path')].append(el.getAttribute('revision')) for k, (v0, v1) in p_r_map.items(): if v0 != v1: print '#### %s\t%s..%s' % (k, v0, v1) cmdstr = 'git --git-dir=%s log %s..%s' % (os.path.join(opts.source, k, '.git'), v0, v1) cmd = WrapCommand(cmdstr) cmd.start() cmd.join() if cmd.returncode != 0: raise Exception('Error run: %s\nReturn code: %s\nError msg: %s' % (cmdstr, cmd.returncode, ''.join(cmd.results[1]))) print cmd.results[0] sys.exit(0) cmd = WrapCommand('repo sync') import ipdb; ipdb.set_trace()