All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GaudiTest.CMT Class Reference

Public Member Functions

def __init__
 
def __getattr__
 
def runtime_env
 
def show_macro
 

Public Attributes

 path
 

Private Member Functions

def _run_cmt
 

Detailed Description

Small wrapper to call CMT.

Definition at line 234 of file GaudiTest.py.

Constructor & Destructor Documentation

def GaudiTest.CMT.__init__ (   self,
  path = None 
)

Definition at line 237 of file GaudiTest.py.

238  def __init__(self,path=None):
239  if path is None:
240  path = os.getcwd()
241  self.path = path

Member Function Documentation

def GaudiTest.CMT.__getattr__ (   self,
  attr 
)

Definition at line 259 of file GaudiTest.py.

260  def __getattr__(self,attr):
261  return lambda args=[]: self._run_cmt(attr, args)
def GaudiTest.CMT._run_cmt (   self,
  command,
  args 
)
private

Definition at line 242 of file GaudiTest.py.

243  def _run_cmt(self,command,args):
244  # prepare command line
245  if type(args) is str:
246  args = [args]
247  cmd = "cmt %s"%command
248  for arg in args:
249  cmd += ' "%s"'%arg
250 
251  # go to the execution directory
252  olddir = os.getcwd()
253  os.chdir(self.path)
254  # run cmt
255  result = os.popen4(cmd)[1].read()
256  # return to the old directory
257  os.chdir(olddir)
258  return result
string type
Definition: gaudirun.py:126
def GaudiTest.CMT.runtime_env (   self,
  env = None 
)
Returns a dictionary containing the runtime environment produced by CMT.
If a dictionary is passed a modified instance of it is returned.

Definition at line 262 of file GaudiTest.py.

263  def runtime_env(self,env = None):
264  """Returns a dictionary containing the runtime environment produced by CMT.
265  If a dictionary is passed a modified instance of it is returned.
266  """
267  if env is None:
268  env = {}
269  for l in self.setup("-csh").splitlines():
270  l = l.strip()
271  if l.startswith("setenv"):
272  dummy,name,value = l.split(None,3)
273  env[name] = value.strip('"')
274  elif l.startswith("unsetenv"):
275  dummy,name = l.split(None,2)
276  if name in env:
277  del env[name]
return env
def GaudiTest.CMT.show_macro (   self,
  k 
)

Definition at line 278 of file GaudiTest.py.

279  def show_macro(self,k):
280  r = self.show(["macro",k])
281  if r.find("CMT> Error: symbol not found") >= 0:
282  return None
283  else:
284  return self.show(["macro_value",k]).strip()
285 

Member Data Documentation

GaudiTest.CMT.path

Definition at line 240 of file GaudiTest.py.


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