/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes | Properties | Private Attributes
DybPython::cmd::Cmd Class Reference

List of all members.

Public Member Functions

def __init__
def __repr__
def interact
def __call__

Public Attributes

 rc
 ret

Properties

 cmd = property(lambda self:self._cmd % self)
 detail = property(lambda self:"%s\n =>\n%s" % (repr(self), self.ret ))

Private Attributes

 _cmd

Detailed Description

Definition at line 20 of file cmd.py.


Constructor & Destructor Documentation

def DybPython::cmd::Cmd::__init__ (   self,
  args,
  kwa 
)

Definition at line 21 of file cmd.py.

00022                                      :
00023         dict.__init__(self, **kwa )
00024         assert len(args) == 1, "expecting single command positional argument "
00025         self._cmd = args[0] 
00026         self.rc = None
00027         self.ret = None


Member Function Documentation

def DybPython::cmd::Cmd::__repr__ (   self)

Definition at line 30 of file cmd.py.

00031                       :
00032         return "%s : %s rc %s " % (self.__class__.__name__, self.cmd, self.rc )

def DybPython::cmd::Cmd::interact (   self,
  prompt = 'Enter YES to proceed with chain : ',
  condition = lambda _:_ == "YES" 
)

Definition at line 33 of file cmd.py.

00033                                                                : ', condition=lambda _:_ == "YES" ):
00034         s = raw_input(prompt)
00035         return condition(s)
00036 
def DybPython::cmd::Cmd::__call__ (   self)
:return: True to proceed with subsequent commands, False to stop

Definition at line 37 of file cmd.py.

00038                       :
00039         """
00040         :return: True to proceed with subsequent commands, False to stop
00041         """ 
00042         cmd = self.cmd
00043         prompt = self.get('prompt',None)
00044         if prompt:
00045             #log.info("prompt %s " % prompt ) 
00046             condition = self.get('condition', lambda _:_ == "")
00047             proceed = self.interact(prompt=prompt, condition=condition )
00048             if not proceed:return 100
00049 
00050         pipe = os.popen(cmd, "r")
00051         ret = pipe.read()
00052         rc = pipe.close()
00053         rc = 0 if not(rc) else rc >> 8
00054 
00055         self.rc = rc
00056         self.ret = ret
00057         log.info(self.detail)
00058 
00059         if rc != 0:
00060             proceed = self.interact(prompt="Non-zero return code : enter IGNORE to proceed ", condition=lambda _:_ == "IGNORE" )
00061             if not proceed:return rc
00062         return 0
00063 
00064 


Member Data Documentation

Definition at line 21 of file cmd.py.

Definition at line 21 of file cmd.py.

Definition at line 21 of file cmd.py.


Property Documentation

DybPython::cmd::Cmd::cmd = property(lambda self:self._cmd % self) [static]

Definition at line 28 of file cmd.py.

DybPython::cmd::Cmd::detail = property(lambda self:"%s\n =>\n%s" % (repr(self), self.ret )) [static]

Definition at line 29 of file cmd.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:55:40 for DybPython by doxygen 1.7.4