Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Attributes | List of all members
python.extractor_dict.MetaData Class Reference
Inheritance diagram for python.extractor_dict.MetaData:
python.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 33 of file extractor_dict.py.

Constructor & Destructor Documentation

def python.extractor_dict.MetaData.__init__ (   self,
  inputfile 
)

Definition at line 38 of file extractor_dict.py.

38  def __init__(self, inputfile):
39  self.inputfile = inputfile
40 
def __init__(self, inputfile)

Member Function Documentation

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

Definition at line 41 of file extractor_dict.py.

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

Definition at line 55 of file extractor_dict.py.

55  def get_job(self, proc):
56  """Run the proc in a 60-sec timeout queue, return stdout, stderr"""
57  q = queue.Queue()
58  thread = threading.Thread(target=self.wait_for_subprocess, args=[proc, q])
59  thread.start()
60  thread.join(timeout=60)
61  if thread.is_alive():
62  print('Terminating subprocess because of timeout.')
63  proc.terminate()
64  thread.join()
65  rc = q.get()
66  jobout = convert_str(q.get())
67  joberr = convert_str(q.get())
68  if rc != 0:
69  raise RuntimeError('sam_metadata_dumper returned nonzero exit status {}.'.format(rc))
70  return jobout, joberr
71 
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
def wait_for_subprocess(jobinfo, q)
def python.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 95 of file extractor_dict.py.

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

Definition at line 84 of file extractor_dict.py.

84  def mdart_gen(jobtuple):
85  """Take Jobout and Joberr (in jobtuple) and return mdart object from that"""
86  mdtext = ''.join(line.replace(", ,", ",") for line in jobtuple[0].split('\n') if line[-3:-1] != ' ,')
87  mdtop = json.JSONDecoder().decode(mdtext)
88  if len(list(mdtop.keys())) == 0:
89  print('No top-level key in extracted metadata.')
90  sys.exit(1)
91  file_name = list(mdtop.keys())[0]
92  return mdtop[file_name]
93 
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 python.extractor_dict.MetaData.wait_for_subprocess (   jobinfo,
  q 
)
static
Run jobinfo, put the return code, stdout, and stderr into a queue

Definition at line 73 of file extractor_dict.py.

73  def wait_for_subprocess(jobinfo, q):
74  """Run jobinfo, put the return code, stdout, and stderr into a queue"""
75  jobout, joberr = jobinfo.communicate()
76  jobout = convert_str(jobout)
77  joberr = convert_str(joberr)
78  rc = jobinfo.poll()
79  for item in (rc, jobout, joberr):
80  q.put(item)
81  return
82 
def wait_for_subprocess(jobinfo, q)

Member Data Documentation

python.extractor_dict.MetaData.__metaclass__ = abc.ABCMeta
staticprivate

Definition at line 35 of file extractor_dict.py.

python.extractor_dict.MetaData.inputfile

Definition at line 39 of file extractor_dict.py.


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