def ssh_run_command(ip, command): result = None ssh = Popen( [ 'ssh', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', '-i', 'id_rsa.travis', 'root@{}'.format(ip), command ], shell=False, stdout=PIPE, stderr=PIPE ) (stdout, stderr) = ssh.communicate() logger(colored('{}: pid = {}, stdout = {}, stderr = {}, rc = {}'.format( inspect.stack()[0][3], ssh.pid, stdout.splitlines(), stderr.splitlines(), ssh.returncode ), 'grey')) return dict({ 'stdout': stdout.splitlines(), 'stderr': stderr.splitlines(), 'rc': ssh.returncode, 'pid': ssh.pid })
def ssh_run_command(ip, command): result = None ssh = Popen(['ssh', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', '-i', 'id_rsa.travis', 'root@%s' % ip, command], shell=False, stdout=PIPE, stderr=PIPE) (stdout, stderr) = ssh.communicate() print colored('%s: pid = %d, stdout = %s, stderr = %s, rc = %d' % (inspect.stack()[0][3], ssh.pid, stdout.splitlines(), stderr.splitlines(), ssh.returncode), 'grey') return dict({'stdout': stdout.splitlines(), 'stderr': stderr.splitlines(), 'rc': ssh.returncode, 'pid': ssh.pid})
def invoke_tool(command, tool_name, input='', on_result=None, filename=None, on_line=None, check_enabled=True, **popen_kwargs): if check_enabled and (not get_setting_async(tool_enabled(tool_name))): return None # extended_env = get_extended_env() source_dir = get_source_dir(filename) def mk_result(s): return on_result(s) if on_result else s try: with ProcHelper(command, input, cwd=source_dir, **popen_kwargs) as p: exit_code, stdout, stderr = p.wait() if exit_code != 0: raise Exception( '{0} exited with exit code {1} and stderr: {2}'.format( tool_name, exit_code, stderr)) if on_line: for l in stdout.splitlines(): on_line(mk_result(l)) else: return mk_result(stdout) except OSError as e: if e.errno == errno.ENOENT: output_error_async( sublime.active_window(), "SublimeHaskell: {0} was not found!\n'{1}' is set to False" .format(tool_name, tool_enabled(tool_name))) set_setting_async(tool_enabled(tool_name), False) else: log( '{0} fails with {1}, command: {2}'.format( tool_name, e, command), log_error) return None except Exception as e: log( '{0} fails with {1}, command: {2}'.format( tool_name, e, command), log_error) return None