Public Member Functions | Public Attributes | Static Public Attributes | List of all members
wirecell.command.WireCell Class Reference

Public Member Functions

def __init__ (self, executable='wire-cell', kwds)
 
def cmdline (self, app=None)
 
def __call__ (self, app=None, config=None)
 
def component_configlist (self, components)
 

Public Attributes

 prog
 
 plugins
 
 config
 
 app
 

Static Public Attributes

list default_plugins = ['WireCellAlg', 'WireCellGen', 'WireCellApps', 'WireCellTbb']
 

Detailed Description

Python interface to wire-cell executable.

Beware, this trusts its input!  In particular do not let
<executable> be set by untrusted sources.

Definition at line 88 of file command.py.

Constructor & Destructor Documentation

def wirecell.command.WireCell.__init__ (   self,
  executable = 'wire-cell',
  kwds 
)

Definition at line 97 of file command.py.

97  def __init__(self, executable='wire-cell', **kwds):
98  self.prog = executable
99  self.plugins = kwds.pop('plugins', self.default_plugins)
100  self.config = Config(**kwds)
101  self.app = kwds.get('app',None)
102 
def __init__(self, executable='wire-cell', kwds)
Definition: command.py:97

Member Function Documentation

def wirecell.command.WireCell.__call__ (   self,
  app = None,
  config = None 
)
Run wire-cell.

If app is not given then fall back to one given to constructor.

If any config is given it is merged with any given to constructor.

Definition at line 114 of file command.py.

114  def __call__(self, app=None, config=None):
115  '''Run wire-cell.
116 
117  If app is not given then fall back to one given to constructor.
118 
119  If any config is given it is merged with any given to constructor.
120 
121  '''
122  cmd = self.cmdline(app)
123  #print 'CMD:\n%s'%cmd
124  cfg = self.config.merge(config).wcjson()
125  #print 'CFG:\n%s'%cfg
126  proc = subprocess.Popen(cmd, shell=True,
127  stdin = subprocess.PIPE,
128  stdout = subprocess.PIPE,
129  stderr = subprocess.PIPE)
130  out,err= proc.communicate(cfg)
131  #print 'OUT:\n%s'%out
132  #print 'ERR:\n%s'%err
133  return out,err
134 
def __call__(self, app=None, config=None)
Definition: command.py:114
def cmdline(self, app=None)
Definition: command.py:103
def wirecell.command.WireCell.cmdline (   self,
  app = None 
)
Return command line string

Definition at line 103 of file command.py.

103  def cmdline(self, app=None):
104  '''
105  Return command line string
106  '''
107  parts = ['%s -c /dev/stdin' % self.prog]
108  parts += ['-p %s'%p for p in self.plugins]
109  app = app or self.app
110  if app:
111  parts.append('-a %s' % app)
112  return ' '.join(parts)
113 
def cmdline(self, app=None)
Definition: command.py:103
def wirecell.command.WireCell.component_configlist (   self,
  components 
)
Return a config list giving configuration for components

Definition at line 135 of file command.py.

135  def component_configlist(self, *components):
136  '''
137  Return a config list giving configuration for components
138  '''
139  config = Config()
140  config.load_one("ConfigDumper","", data=dict(components = components))
141  o,e = self("ConfigDumper", config=config)
142  return json.loads(o)
143 
144 
def component_configlist(self, components)
Definition: command.py:135

Member Data Documentation

wirecell.command.WireCell.app

Definition at line 101 of file command.py.

wirecell.command.WireCell.config

Definition at line 100 of file command.py.

list wirecell.command.WireCell.default_plugins = ['WireCellAlg', 'WireCellGen', 'WireCellApps', 'WireCellTbb']
static

Definition at line 95 of file command.py.

wirecell.command.WireCell.plugins

Definition at line 99 of file command.py.

wirecell.command.WireCell.prog

Definition at line 98 of file command.py.


The documentation for this class was generated from the following file: