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

string mdtext = ''
 mdtext = ''.join(line.replace(", ,", ",") for line in jobtuple[0].split('
') if line[-3:-1] != ' ,') More...
 
 mdtop = json.JSONDecoder().decode(mdtext)
 
 file_name = list(mdtop.keys())[0]
 

Static Private Attributes

 __metaclass__ = abc.ABCMeta
 

Detailed Description

Base class to hold / interpret general metadata

Definition at line 33 of file extractor_prod.py.

Constructor & Destructor Documentation

def extractor_prod.MetaData.__init__ (   self,
  inputfile 
)

Definition at line 38 of file extractor_prod.py.

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

Member Function Documentation

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

Definition at line 41 of file extractor_prod.py.

42  """Extract metadata from inputfile into a pipe for further processing."""
43  local = self.inputfile
44  if len(local) > 0:
45  proc = Popen(["sam_metadata_dumper", local], stdout=PIPE,
46  stderr=PIPE)
47  else:
48  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 extract_metadata_to_pipe(self)
def extractor_prod.MetaData.get_job (   self,
  proc 
)
Run the proc in a 60-sec timeout queue, return stdout, stderr

Definition at line 55 of file extractor_prod.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=7200)
61  if thread.is_alive():
62  print('Terminating subprocess because of timeout.')
63  proc.terminate()
64  thread.join()
65  rc = q.get()
66  jobout = q.get()
67  joberr = q.get()
68  if rc != 0:
69  raise RuntimeError('sam_metadata_dumper returned nonzero exit status {}.'.format(rc))
70  return jobout, joberr
71 
def get_job(self, proc)
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
def wait_for_subprocess(jobinfo, q)
def extractor_prod.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 94 of file extractor_prod.py.

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

Definition at line 82 of file extractor_prod.py.

82  def mdart_gen(jobtuple):
83  """Take Jobout and Joberr (in jobtuple) and return mdart object from that"""
def extractor_prod.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_prod.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  rc = jobinfo.poll()
77  for item in (rc, jobout, joberr):
78  q.put(item)
79  return
80 
def wait_for_subprocess(jobinfo, q)

Member Data Documentation

extractor_prod.MetaData.__metaclass__ = abc.ABCMeta
staticprivate

Definition at line 35 of file extractor_prod.py.

extractor_prod.MetaData.file_name = list(mdtop.keys())[0]
static

Definition at line 90 of file extractor_prod.py.

extractor_prod.MetaData.inputfile

Definition at line 39 of file extractor_prod.py.

string extractor_prod.MetaData.mdtext = ''
static

mdtext = ''.join(line.replace(", ,", ",") for line in jobtuple[0].split('
') if line[-3:-1] != ' ,')

Definition at line 85 of file extractor_prod.py.

extractor_prod.MetaData.mdtop = json.JSONDecoder().decode(mdtext)
static

Definition at line 86 of file extractor_prod.py.


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