Class SpawnedCommand
source code
object --+
|
SpawnedCommand
Implements a command which can be started easily by specifying a class path
such as package.cmd.module.CommandClass whose instance should be started in
a standalone process.
The target command must be derived from this class and must implement the
'execute' method.
To use this class, derive from it and change the configuration variables
accordingly.
The instance will always own a logger instance at its member called 'log',
the configuration will be applied according to k_log_application_id
The parser used to parse all options is vailable at its member called 'parser',
its set during option_parser
The instance may also be created within an existing process and
executed manually - in that case it will not exit automatically if a
serious event occours
|
__init__(self,
*args,
**kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
source code
|
|
|
|
|
_execute(self,
*args)
internal method handling the basic arguments in a pre-process before
calling execute |
source code
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
|
execute(self,
*args,
**kwargs)
Method implementing the actual functionality of the command
:param options: Values instance of the optparse module
:param args: remaining positional arguments passed to the process on the commandline
:note: if you like to terminate, raise an exception |
source code
|
|
|
|
|
spawn(cls,
*args,
**kwargs)
Spawn a new standalone process of this command type
Additional arguments passed to the command process |
source code
|
|
|
daemonize(cls,
*args)
Damonize the spawned command, passing *args to the instanciated command's
execute method. |
source code
|
|
|
_daemon_redirect_to = ' /dev/null '
|
|
k_log_application_id = None
hash(x)
|
|
k_class_path = ' package.module.YourClass '
|
|
k_version = None
hash(x)
|
|
_exec_path = ' /media/truecrypt2/mainline/pipe/master/pipe/ext/ ...
|
|
_mrv_info_dir = None
hash(x)
|
|
_add_args = [ ' --mrv-no-maya ' ]
|
|
k_usage = None
hash(x)
|
|
k_description = None
hash(x)
|
|
k_program_name = None
hash(x)
|
|
_daemon_umask = None
hash(x)
|
|
_daemon_workdir = None
hash(x)
|
|
_daemon_maxfd = 64
|
|
log
|
|
parser
|
Inherited from object :
__class__
|
__init__(self,
*args,
**kwargs)
(Constructor)
| source code
|
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
- Parameters:
_spawned - If True, default False, we assume we have our own process.
Otherwise we will do nothing that would adjust the current process, such as:
- sys.exit
- change configuration of logging system
- Overrides:
object.__init__
|
Spawn a new standalone process of this command type
Additional arguments passed to the command process
Returns: Subprocess.Popen instance
- Parameters:
kwargs - Additional keyword arguments to be passed to Subprocess.Popen,
use it to configure your IO
|
Damonize the spawned command, passing *args to the instanciated command's
execute method.
- Returns:
- None in calling process, no return in the daemon
as sys.exit will be called.
|
The arguments can be preprocessed
- Returns:
- tuple(options, args) tuple of parsed options and remaining args
|
internal method handling the basic arguments in a pre-process before
calling execute
We will parse all options, process the default ones and pass on the
call to the execute method
|
Method implementing the actual functionality of the command
:param options: Values instance of the optparse module
:param args: remaining positional arguments passed to the process on the commandline
:note: if you like to terminate, raise an exception
- Decorators:
|
- Returns:
- OptionParser Instance containing all supported options
Note:
Should be overridden by subclass to add additional options and
option groups themselves after calling the base class implementation
|
_exec_path
- Value:
' /media/truecrypt2/mainline/pipe/master/pipe/ext/mrv/mrv/bin/mrv '
|
|