]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix PEP-8 issues
authorZack Cerza <zack@cerza.org>
Thu, 8 May 2014 23:44:15 +0000 (18:44 -0500)
committerZack Cerza <zack@cerza.org>
Sat, 10 May 2014 14:10:22 +0000 (09:10 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/orchestra/run.py

index c8ab2c6f96ed33f2df74db08876ba7e8bb624dd9..7ff637c0fb3e9cd2f1b5ff2a6d1e8f6eaa922a97 100644 (file)
@@ -14,7 +14,9 @@ from ..contextutil import safe_while
 
 log = logging.getLogger(__name__)
 
+
 class RemoteProcess(object):
+
     """
     Remote process object used to keep track of attributes of a process.
     """
@@ -23,6 +25,7 @@ class RemoteProcess(object):
         # for orchestra.remote.Remote to place a backreference
         'remote',
         ]
+
     def __init__(self, command, stdin, stdout, stderr, exitstatus, exited):
         self.command = command
         self.stdin = stdin
@@ -31,7 +34,9 @@ class RemoteProcess(object):
         self.exitstatus = exitstatus
         self.exited = exited
 
+
 class Raw(object):
+
     """
     Raw objects are passed to remote objects and are not processed locally.
     """
@@ -44,6 +49,7 @@ class Raw(object):
             value=self.value,
             )
 
+
 def quote(args):
     """
     Internal quote wrapper.
@@ -117,6 +123,7 @@ def execute(client, args, name=None):
         )
     return r
 
+
 def copy_to_log(f, logger, host, loglevel=logging.INFO):
     """
     Interface to older xreadlines api.
@@ -133,6 +140,7 @@ def copy_to_log(f, logger, host, loglevel=logging.INFO):
         line = unicode(line, 'utf-8', 'replace').encode('utf-8')
         logger.log(loglevel, '[' + host + ']: ' + line)
 
+
 def copy_and_close(src, fdst):
     """
     copyfileobj call wrapper.
@@ -143,6 +151,7 @@ def copy_and_close(src, fdst):
         shutil.copyfileobj(src, fdst)
     fdst.close()
 
+
 def copy_file_to(f, dst, host):
     """
     Copy file
@@ -161,6 +170,7 @@ def copy_file_to(f, dst, host):
 
 
 class CommandFailedError(Exception):
+
     """
     Exception thrown on command failure
     """
@@ -170,14 +180,15 @@ class CommandFailedError(Exception):
         self.node = node
 
     def __str__(self):
-        return "Command failed on {node} with status {status}: {command!r}".format(
+        return "Command failed on {node} with status {status}: {cmd!r}".format(
             node=self.node,
             status=self.exitstatus,
-            command=self.command,
+            cmd=self.command,
             )
 
 
 class CommandCrashedError(Exception):
+
     """
     Exception thrown on crash
     """
@@ -191,6 +202,7 @@ class CommandCrashedError(Exception):
 
 
 class ConnectionLostError(Exception):
+
     """
     Exception thrown when the connection is lost
     """
@@ -202,6 +214,7 @@ class ConnectionLostError(Exception):
             command=self.command,
             )
 
+
 def spawn_asyncresult(fn, *args, **kwargs):
     """
     Spawn a Greenlet and pass it's results to an AsyncResult.
@@ -213,6 +226,7 @@ def spawn_asyncresult(fn, *args, **kwargs):
     AsyncResult avoids this.
     """
     r = gevent.event.AsyncResult()
+
     def wrapper():
         """
         Internal wrapper.
@@ -227,7 +241,9 @@ def spawn_asyncresult(fn, *args, **kwargs):
 
     return r
 
+
 class Sentinel(object):
+
     """
     Sentinel -- used to define PIPE file-like object.
     """
@@ -239,7 +255,9 @@ class Sentinel(object):
 
 PIPE = Sentinel('PIPE')
 
+
 class KludgeFile(object):
+
     """
     Wrap Paramiko's ChannelFile in a way that lets ``f.close()``
     actually cause an EOF for the remote command.
@@ -265,20 +283,31 @@ def run(
     check_status=True,
     wait=True,
     name=None
-    ):
+):
     """
     Run a command remotely.
 
     :param client: SSHConnection to run the command with
     :param args: command to run
     :type args: list of string
-    :param stdin: Standard input to send; either a string, a file-like object, None, or `PIPE`. `PIPE` means caller is responsible for closing stdin, or command may never exit.
-    :param stdout: What to do with standard output. Either a file-like object, a `logging.Logger`, `PIPE`, or `None` for copying to default log. `PIPE` means caller is responsible for reading, or command may never exit.
+    :param stdin: Standard input to send; either a string, a file-like object,
+                  None, or `PIPE`. `PIPE` means caller is responsible for
+                  closing stdin, or command may never exit.
+    :param stdout: What to do with standard output. Either a file-like object,
+                   a `logging.Logger`, `PIPE`, or `None` for copying to default
+                   log. `PIPE` means caller is responsible for reading, or
+                   command may never exit.
     :param stderr: What to do with standard error. See `stdout`.
-    :param logger: If logging, write stdout/stderr to "out" and "err" children of this logger. Defaults to logger named after this module.
-    :param check_status: Whether to raise CommandFailedError on non-zero exit status, and . Defaults to True. All signals and connection loss are made to look like SIGHUP.
-    :param wait: Whether to wait for process to exit. If False, returned ``r.exitstatus`` s a `gevent.event.AsyncResult`, and the actual status is available via ``.get()``.
-    :param name: Human readable name (probably hostname) of the destination host
+    :param logger: If logging, write stdout/stderr to "out" and "err" children
+                   of this logger. Defaults to logger named after this module.
+    :param check_status: Whether to raise CommandFailedError on non-zero exit
+                         status, and . Defaults to True. All signals and
+                         connection loss are made to look like SIGHUP.
+    :param wait: Whether to wait for process to exit. If False, returned
+                 ``r.exitstatus`` s a `gevent.event.AsyncResult`, and the
+                 actual status is available via ``.get()``.
+    :param name: Human readable name (probably hostname) of the destination
+                 host
     """
     (host, port) = client.get_transport().getpeername()
 
@@ -294,7 +323,8 @@ def run(
         g_in = gevent.spawn(copy_and_close, stdin, r.stdin)
         r.stdin = None
     else:
-        assert not wait, "Using PIPE for stdin without wait=False would deadlock."
+        assert not wait, \
+            "Using PIPE for stdin without wait=False would deadlock."
 
     if logger is None:
         logger = log
@@ -306,7 +336,8 @@ def run(
         g_err = gevent.spawn(copy_file_to, r.stderr, stderr, name)
         r.stderr = stderr
     else:
-        assert not wait, "Using PIPE for stderr without wait=False would deadlock."
+        assert not wait, \
+            "Using PIPE for stderr without wait=False would deadlock."
 
     g_out = None
     if stdout is not PIPE:
@@ -315,7 +346,8 @@ def run(
         g_out = gevent.spawn(copy_file_to, r.stdout, stdout, name)
         r.stdout = stdout
     else:
-        assert not wait, "Using PIPE for stdout without wait=False would deadlock."
+        assert not wait, \
+            "Using PIPE for stdout without wait=False would deadlock."
 
     def _check_status(status):
         """
@@ -343,7 +375,8 @@ def run(
                 # signal; sadly SSH does not tell us which signal
                 raise CommandCrashedError(command=r.command)
             if status != 0:
-                raise CommandFailedError(command=r.command, exitstatus=status, node=name)
+                raise CommandFailedError(
+                    command=r.command, exitstatus=status, node=name)
         return status
 
     if wait: