Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: third_party/gsutil/boto/boto/manage/cmdshell.py

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/gsutil/boto/boto/manage/__init__.py ('k') | third_party/gsutil/boto/boto/manage/propget.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/gsutil/boto/boto/manage/cmdshell.py
diff --git a/third_party/gsutil/20110627/boto/boto/manage/cmdshell.py b/third_party/gsutil/boto/boto/manage/cmdshell.py
similarity index 83%
rename from third_party/gsutil/20110627/boto/boto/manage/cmdshell.py
rename to third_party/gsutil/boto/boto/manage/cmdshell.py
index d0e6158e1f61709c723637ad1ab9638cdf158e95..b21898c02d0c6c1d4a1dadd6a3c2aebeab2605fd 100644
--- a/third_party/gsutil/20110627/boto/boto/manage/cmdshell.py
+++ b/third_party/gsutil/boto/boto/manage/cmdshell.py
@@ -72,21 +72,28 @@ class SSHClient(object):
retry += 1
print 'Could not establish SSH connection'
+ def open_sftp(self):
+ return self._ssh_client.open_sftp()
+
def get_file(self, src, dst):
- sftp_client = self._ssh_client.open_sftp()
+ sftp_client = self.open_sftp()
sftp_client.get(src, dst)
def put_file(self, src, dst):
- sftp_client = self._ssh_client.open_sftp()
+ sftp_client = self.open_sftp()
sftp_client.put(src, dst)
+ def open(self, filename, mode='r', bufsize=-1):
+ """
+ Open a file on the remote system and return a file-like object.
+ """
+ sftp_client = self.open_sftp()
+ return sftp_client.open(filename, mode, bufsize)
+
def listdir(self, path):
- sftp_client = self._ssh_client.open_sftp()
+ sftp_client = self.open_sftp()
return sftp_client.listdir(path)
- def open_sftp(self):
- return self._ssh_client.open_sftp()
-
def isdir(self, path):
status = self.run('[ -d %s ] || echo "FALSE"' % path)
if status[1].startswith('FALSE'):
@@ -100,24 +107,43 @@ class SSHClient(object):
return 1
def shell(self):
+ """
+ Start an interactive shell session on the remote host.
+ """
channel = self._ssh_client.invoke_shell()
interactive_shell(channel)
def run(self, command):
- boto.log.info('running:%s on %s' % (command, self.server.instance_id))
- log_fp = StringIO.StringIO()
+ """
+ Execute a command on the remote host. Return a tuple containing
+ an integer status and a two strings, the first containing stdout
+ and the second containing stderr from the command.
+ """
+ boto.log.debug('running:%s on %s' % (command, self.server.instance_id))
status = 0
try:
t = self._ssh_client.exec_command(command)
except paramiko.SSHException:
status = 1
- log_fp.write(t[1].read())
- log_fp.write(t[2].read())
+ std_out = t[1].read()
+ std_err = t[2].read()
t[0].close()
t[1].close()
t[2].close()
- boto.log.info('output: %s' % log_fp.getvalue())
- return (status, log_fp.getvalue())
+ boto.log.debug('stdout: %s' % std_out)
+ boto.log.debug('stderr: %s' % std_err)
+ return (status, std_out, std_err)
+
+ def run_pty(self, command):
+ """
+ Execute a command on the remote host with a pseudo-terminal.
+ Returns a string containing the output of the command.
+ """
+ boto.log.debug('running:%s on %s' % (command, self.server.instance_id))
+ channel = self._ssh_client.get_transport().open_session()
+ channel.get_pty()
+ channel.exec_command(command)
+ return channel
def close(self):
transport = self._ssh_client.get_transport()
« no previous file with comments | « third_party/gsutil/boto/boto/manage/__init__.py ('k') | third_party/gsutil/boto/boto/manage/propget.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698