Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Attributes | List of all members
extractor_dict.MetaData Class Reference
Inheritance diagram for extractor_dict.MetaData:
extractor_dict.expMetaData

Public Member Functions

def __init__ (self, inputfile)
 
def extract_metadata_to_pipe (self)
 
def get_job (self, proc)
 

Static Public Member Functions

def wait_for_subprocess (jobinfo, q)
 
def mdart_gen (jobtuple)
 
def md_handle_application (md)
 

Public Attributes

 inputfile
 

Static Private Attributes

 __metaclass__ = abc.ABCMeta
 

Detailed Description

Base class to hold / interpret general metadata

Definition at line 30 of file extractor_dict.py.

Constructor & Destructor Documentation

def extractor_dict.MetaData.__init__ (   self,
  inputfile 
)

Definition at line 35 of file extractor_dict.py.

35  def __init__(self, inputfile):
36  self.inputfile = inputfile
37 
def __init__(self, inputfile)

Member Function Documentation

def extractor_dict.MetaData.extract_metadata_to_pipe (   self)
Extract metadata from inputfile into a pipe for further processing.

Definition at line 38 of file extractor_dict.py.

39  """Extract metadata from inputfile into a pipe for further processing."""
40  local = project_utilities.path_to_local(self.inputfile)
41  if len(local) > 0:
42  proc = Popen(["sam_metadata_dumper", local], stdout=PIPE,
43  stderr=PIPE)
44  else:
45  url = project_utilities.path_to_url(inputfile)
46  proc = Popen(["sam_metadata_dumper", url], stdout=PIPE,
47  stderr=PIPE)
48  if len(local) > 0 and local != self.inputfile:
49  os.remove(local)
50  return proc
51 
def extract_metadata_to_pipe(self)
def extractor_dict.MetaData.get_job (   self,
  proc 
)
Run the proc in a 60-sec timeout queue, return stdout, stderr

Definition at line 52 of file extractor_dict.py.

52  def get_job(self, proc):
53  """Run the proc in a 60-sec timeout queue, return stdout, stderr"""
54  q = queue.Queue()
55  thread = threading.Thread(target=self.wait_for_subprocess, args=[proc, q])
56  thread.start()
57  thread.join(timeout=60)
58  if thread.is_alive():
59  print('Terminating subprocess because of timeout.')
60  proc.terminate()
61  thread.join()
62  rc = q.get()
63  jobout = q.get()
64  joberr = q.get()
65  if rc != 0:
66  raise RuntimeError('sam_metadata_dumper returned nonzero exit status {}.'.format(rc))
67  return jobout, joberr
68 
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
def get_job(self, proc)
def wait_for_subprocess(jobinfo, q)
def extractor_dict.MetaData.md_handle_application (   md)
static
If there's no application key in md dict, create the key with a blank dictionary.
Then return md['application'], along with mdval

Definition at line 90 of file extractor_dict.py.

91  """If there's no application key in md dict, create the key with a blank dictionary.
92  Then return md['application'], along with mdval"""
93  if 'application' not in md:
94  md['application'] = {}
95  return md['application']
96 
97 
def extractor_dict.MetaData.mdart_gen (   jobtuple)
static
Take Jobout and Joberr (in jobtuple) and return mdart object from that

Definition at line 79 of file extractor_dict.py.

79  def mdart_gen(jobtuple):
80  """Take Jobout and Joberr (in jobtuple) and return mdart object from that"""
81  mdtext = ''.join(line.replace(", ,", ",") for line in jobtuple[0].split('\n') if line[-3:-1] != ' ,')
82  mdtop = json.JSONDecoder().decode(mdtext)
83  if len(mdtop.keys()) == 0:
84  print('No top-level key in extracted metadata.')
85  sys.exit(1)
86  file_name = mdtop.keys()[0]
87  return mdtop[file_name]
88 
void decode(std::any const &a, Hep2Vector &result)
Definition: CLHEP_ps.h:12
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35
def extractor_dict.MetaData.wait_for_subprocess (   jobinfo,
  q 
)
static
Run jobinfo, put the return code, stdout, and stderr into a queue

Definition at line 70 of file extractor_dict.py.

70  def wait_for_subprocess(jobinfo, q):
71  """Run jobinfo, put the return code, stdout, and stderr into a queue"""
72  jobout, joberr = jobinfo.communicate()
73  rc = jobinfo.poll()
74  for item in (rc, jobout, joberr):
75  q.put(item)
76  return
77 
def wait_for_subprocess(jobinfo, q)

Member Data Documentation

extractor_dict.MetaData.__metaclass__ = abc.ABCMeta
staticprivate

Definition at line 32 of file extractor_dict.py.

extractor_dict.MetaData.inputfile

Definition at line 36 of file extractor_dict.py.


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