ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
python.ChapPy.AthenaApp Class Reference

AthenaApp. More...

Inheritance diagram for python.ChapPy.AthenaApp:
Collaboration diagram for python.ChapPy.AthenaApp:

Public Member Functions

def __init__ (self, cmdlineargs=None, dump_jobo=None)
 
def include (self, jobo_name)
 
def __lshift__ (self, o)
 
def run (self, stdout=None, env=None)
 

Private Attributes

 _jobo
 
 _jobo_name
 
 _cmdlineargs
 

Detailed Description

AthenaApp.

another way at scripting `athena`

Definition at line 265 of file ChapPy.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ChapPy.AthenaApp.__init__ (   self,
  cmdlineargs = None,
  dump_jobo = None 
)

Definition at line 269 of file ChapPy.py.

269  def __init__(self, cmdlineargs=None, dump_jobo=None):
270 
271  if dump_jobo:
272  self._jobo = open (dump_jobo, 'w+')
273  self._jobo_name = dump_jobo
274  else:
275  import tempfile
276  self._jobo = tempfile.NamedTemporaryFile(suffix='-jobo.py', mode='w+')
277  self._jobo_name = self._jobo.name
278  if cmdlineargs is None:
279  cmdlineargs = []
280  if isinstance(cmdlineargs, str):
281  cmdlineargs = cmdlineargs.split()
282  self._cmdlineargs = cmdlineargs[:]
283 
284  return
285 

Member Function Documentation

◆ __lshift__()

def python.ChapPy.AthenaApp.__lshift__ (   self,
  o 
)

Definition at line 290 of file ChapPy.py.

290  def __lshift__(self, o):
291  if isinstance(o, str):
292  import textwrap
293  self._jobo.write(textwrap.dedent(o))
294  self._jobo.flush()
295  return
296  raise TypeError('unexpected type %s'%type(o))
297 

◆ include()

def python.ChapPy.AthenaApp.include (   self,
  jobo_name 
)

Definition at line 286 of file ChapPy.py.

286  def include(self, jobo_name):
287  self._jobo.write('include("%s")\n'%jobo_name)
288  self._jobo.flush()
289 

◆ run()

def python.ChapPy.AthenaApp.run (   self,
  stdout = None,
  env = None 
)

Definition at line 298 of file ChapPy.py.

298  def run(self, stdout=None, env=None):
299  import os
300  import subprocess as sub
301  if env is None:
302  env=dict(os.environ)
303  athena_exe = sub.Popen(['which', 'athena.py'],
304  stdout=sub.PIPE,
305  env=env).communicate()[0].strip()
306 
307  athena_exe = os.path.expanduser(os.path.expandvars(athena_exe))
308  athena_exe = os.path.realpath(athena_exe)
309  athena_exe = os.path.abspath(athena_exe)
310 
311  #sh = sub.Popen('/bin/sh', stdin=sub.PIPE, stdout=stdout)
312  #sh.stdin.write('%s %s'%(athena_exe,self._jobo.name))
313  if stdout == os.devnull:
314  stdout = open(os.devnull,'w')
315  cmd = [athena_exe] + self._cmdlineargs + [self._jobo_name]
316  return sub.call(cmd,
317  stdout=stdout,
318  stderr=sub.STDOUT,
319  env=env)
320 

Member Data Documentation

◆ _cmdlineargs

python.ChapPy.AthenaApp._cmdlineargs
private

Definition at line 282 of file ChapPy.py.

◆ _jobo

python.ChapPy.AthenaApp._jobo
private

Definition at line 272 of file ChapPy.py.

◆ _jobo_name

python.ChapPy.AthenaApp._jobo_name
private

Definition at line 273 of file ChapPy.py.


The documentation for this class was generated from the following file:
FullCPAlgorithmsTest_eljob.flush
flush
Definition: FullCPAlgorithmsTest_eljob.py:168
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
python.ByteStreamConfig.write
def write
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:248
python.Include.include
include
Definition: Include.py:319
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78