Esempio n. 1
0
 def _split_client_server(self):
     # Split the raw string into client & server sections
     client_lines = []
     server_lines = []
     version_lines = list(self.version_lines)  # work on a copy
     version_lines.reverse()  # start at beginning
     while version_lines:
         version_line = version_lines.pop().strip()
         if version_line == '':
             continue
         elif version_line.find('Client:') > -1:
             # Don't assume which section came first
             while version_lines and version_lines[-1].find('Server:') < 0:
                 version_line = version_lines.pop().strip()
                 if version_line == '':
                     continue
                 client_lines.append(version_line)
             continue
         elif version_line.find('Server:') > -1:
             # Don't assume which section came first
             while version_lines and version_lines[-1].find('Client:') < 0:
                 version_line = version_lines.pop().strip()
                 if version_line == '':
                     continue
                 server_lines.append(version_line)
             continue
         else:
             msg = ("Unexpected line '%s' in version string: '%s'" %
                    (version_line, self.version_string))
             raise xceptions.DockerOutputError(msg)
     return (client_lines, server_lines)
Esempio n. 2
0
 def __init__(self, cmdresult, ignore_error=False, skip=None):
     # Base class __init__ is abstract
     # pylint: disable=W0231
     self.cmdresult = cmdresult
     self.stdout_strip = cmdresult.stdout.strip()
     self.stderr_strip = cmdresult.stderr.strip()
     # All methods called twice with mangled names, mangle skips also
     if skip is not None:
         if isinstance(skip, (str, unicode)):
             skip = [skip]
         newskip = []
         for checker in skip:
             newskip.append(checker + '_stdout')
             newskip.append(checker + '_stderr')
     else:
         newskip = skip
     self.__instattrs__(newskip)
     for checker in [name for name in dir(self) if name.endswith('_check')]:
         self.callables[checker + '_stdout'] = getattr(self, checker)
         self.callables[checker + '_stderr'] = getattr(self, checker)
     self.call_callables()
     # Not nonzero means One or more checkers returned False
     if not ignore_error and not self.__nonzero__():
         # Str representation will provide details
         raise xceptions.DockerOutputError(str(self))
Esempio n. 3
0
 def server(self):
     """
     Read-only property representing version-number string of docker server
     """
     if self._server is None:
         regex = re.compile(r'Server\s*version:\s*(\d+\.\d+\.\d+\S*)',
                            re.IGNORECASE)
         mobj = None
         for line in self.version_lines:
             mobj = regex.search(line.strip())
             if bool(mobj):
                 self._server = mobj.group(1)
     if self._server is None:
         raise xceptions.DockerOutputError("Couldn't parse server version "
                                           "from %s" % self.version_string)
     return self._server
Esempio n. 4
0
 def _oops(self, what):
     raise xceptions.DockerOutputError("Couldn't parse %s "
                                       "from %s" %
                                       (what, self.version_string))