]> git.llucax.com Git - software/pymin.git/commitdiff
Merge branch 'master' of git.llucax.com.ar:/var/lib/git/software/pymin
authorLeandro Lucarella <llucax@gmail.com>
Wed, 19 Dec 2007 17:41:39 +0000 (14:41 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Wed, 19 Dec 2007 17:41:39 +0000 (14:41 -0300)
1  2 
pymin/services/util.py

diff --combined pymin/services/util.py
index f3bb01301778268ceccdb4ea96a068040da29659,a7ec0e4dd906db025ca108421002cb0fb2d908b1..cb97815e2b1bf9892bbf7b1803de06240859350f
@@@ -16,13 -16,13 +16,13 @@@ from pymin.seqtools import Sequenc
  #DEBUG = False
  DEBUG = True
  
- __ALL__ = ('Error', 'ReturnNot0Error', 'ExecutionError', 'ItemError',
-             'ItemAlreadyExistsError', 'ItemNotFoundError', 'ContainerError',
-             'ContainerNotFoundError', 'call', 'get_network_devices',
-             'Persistent', 'Restorable', 'ConfigWriter', 'ServiceHandler',
-             'RestartHandler', 'ReloadHandler', 'InitdHandler', 'SubHandler',
-             'DictSubHandler', 'ListSubHandler', 'ComposedSubHandler',
-             'ListComposedSubHandler', 'DictComposedSubHandler', 'Device','Address')
+ __ALL__ = ('Error', 'ExecutionError', 'ItemError', 'ItemAlreadyExistsError',
+            'ItemNotFoundError', 'ContainerError', 'ContainerNotFoundError',
+            'call', 'get_network_devices', 'Persistent', 'Restorable',
+            'ConfigWriter', 'ServiceHandler', 'RestartHandler',
+            'ReloadHandler', 'InitdHandler', 'SubHandler', 'DictSubHandler',
+            'ListSubHandler', 'ComposedSubHandler', 'ListComposedSubHandler',
+            'DictComposedSubHandler', 'Device','Address')
  
  class Error(HandlerError):
      r"""
      """
      pass
  
- class ReturnNot0Error(Error):
-     r"""
-     ReturnNot0Error(return_value) -> ReturnNot0Error instance.
-     A command didn't returned the expected 0 return value.
-     return_value - Return value returned by the command.
-     """
-     def __init__(self, return_value):
-         r"Initialize the object. See class documentation for more info."
-         self.return_value = return_value
-     def __unicode__(self):
-         return 'The command returned %d' % self.return_value
  class ExecutionError(Error):
      r"""
      ExecutionError(command, error) -> ExecutionError instance.
@@@ -171,11 -155,10 +155,11 @@@ class Device(Sequence)
          self.name = name
          self.mac = mac
          self.ppp = ppp
 +        self.active = True
          self.addrs = dict()
          self.routes = list()
      def as_tuple(self):
 -        return (self.name, self.mac, self.addrs)
 +        return (self.name, self.mac, self.active, self.addrs)
  
  
  
@@@ -233,13 -216,11 +217,11 @@@ def call(command, stdin=subprocess.PIPE
          return
      try:
          print 'Executing command:', command
-         r = subprocess.call(command, stdin=stdin, stdout=stdout, stderr=stderr,
-                                 universal_newlines=universal_newlines,
-                                 close_fds=close_fds, **kw)
+         r = subprocess.check_call(command, stdin=stdin, stdout=stdout,
+                     stderr=stderr, close_fds=close_fds,
+                     universal_newlines=universal_newlines, **kw)
      except Exception, e:
          raise ExecutionError(command, e)
-     if r is not 0:
-         raise ExecutionError(command, ReturnNot0Error(r))
  
  class Persistent:
      r"""Persistent([attrs[, dir[, ext]]]) -> Persistent.