def run_install(qaOpts, g_vars): # update external tables and in case of running qa_dkrz.py from # sources update C++ executables if not qaOpts.isOpt('PROJECT'): qaOpts.setOpt('PROJECT', 'NONE') if not qaOpts.isOpt('PROJECT_AS'): qaOpts.setOpt('PROJECT_AS', qaOpts.getOpt('PROJECT')) if not g_vars.NO_GIT: # checksum of the current qa_dkrz.py md5_0 = qa_util.get_md5sum(sys.argv[0]) p = os.path.join(g_vars.qa_src, 'install') if qaOpts.isOpt('install_args'): p += ' ' + qaOpts.getOpt('install_args') try: subprocess.check_call(p, shell=True) except: return md5_1 = qa_util.get_md5sum(sys.argv[0]) if md5_0 == md5_1: # restart the script pass return
def get_entry_slot_ix(self, entry_id, entry): # id of a previously found self.entry slot if entry_id != '': for d in self.entry_id: if d['id'] == entry_id: return (d['ix'], entry_id) # find something new or released entry_id = qa_util.get_md5sum(entry) while True: if self.entry_lock == '': self.entry_lock = entry_id if self.entry_lock != entry_id: # locked by another process continue # find a free entry list item for ix in range(len(self.entry)): if len(self.entry[ix]) == 0: break else: self.entry.append([]) ix = len(self.entry)-1 # find a free entry_id list item for ei_ix in range(len(self.entry_id)): if self.entry_id[ei_ix]['id'] == '': self.entry_id[ei_ix]['id'] = entry_id self.entry_id[ei_ix]['ix'] = ix break else: self.entry_id.append( {'id': entry_id, 'ix': ix} ) # unlock self.entry_lock = '' break return (ix, entry_id)
def get_entry_slot_ix(self, entry_id, entry): # id of a previously found self.entry slot if entry_id != '': for d in self.entry_id: if d['id'] == entry_id: return (d['ix'], entry_id) # find something new or released entry_id = qa_util.get_md5sum(entry) while True: if self.entry_lock == '': self.entry_lock = entry_id if self.entry_lock != entry_id: # locked by another process continue # find a free entry list item for ix in range(len(self.entry)): if len(self.entry[ix]) == 0: break else: self.entry.append([]) ix = len(self.entry) - 1 # find a free entry_id list item for ei_ix in range(len(self.entry_id)): if self.entry_id[ei_ix]['id'] == '': self.entry_id[ei_ix]['id'] = entry_id self.entry_id[ei_ix]['ix'] = ix break else: self.entry_id.append({'id': entry_id, 'ix': ix}) # unlock self.entry_lock = '' break return (ix, entry_id)
def annot_synthetic_tag(self): # create a synthetic tag for annotations that have none; # this will not eventually be printed. annot_sz = len(self.annot_tag) # there is not a single annotation if annot_sz == 0: return for ix in range(annot_sz): if len(self.annot_tag[ix]) == 0: md5 = qa_util.get_md5sum(self.annot_capt[ix]) # try for 3 digits width = 3 while True: if md5[0:width] in self.annot_tag: width = 4 else: self.annot_tag[ix] = md5[0:width] break return
def convert_CMOR_output(lines): blk_marks = ['!', '='] blk = [] ix = -1 blkOn = False for line in lines: if len(line) == 0 or line[0:11] == 'processing:': continue if line[0:9] == 'Traceback': emergency(lines) return # find the beginning of a block count = 0 for mark in blk_marks: c = line.count(mark) if c > count: count = c if count > 5: if blkOn: blkOn = False else: blkOn = True blk.append([]) ix += 1 continue if blkOn: blk[ix].append(line) # remove disturbing sub-strings for ix in range(len(blk)): for jx in range(len(blk[ix]) - 1, -1, -1): # rm line-feed blk[ix][jx] = blk[ix][jx].strip("\t\n !") if len(blk[ix][jx]) == 0: del blk[ix][jx] else: # replace every ';' by '.', because semi-colon serves as line delimiter # in qa-exec-check if ';' in blk[ix][jx]: blk[ix][jx] = blk[ix][jx].replace(';', '.') # re-sort according to annots (terminated py a period) annot = [] # remove the 'Ceterum censeo Karthaginem esse delendam' phrase if len(blk) > 0: cicero = blk[len(blk) - 1] if 'The input file is not CMIP6 compliant' in cicero[0]: del blk[len(blk) - 1] for ix in range(len(blk)): annot.append([]) phrase = '' for line in blk[ix]: last = len(line) - 1 pos0 = 0 while True: if pos0 == 0 and len(phrase) > 0: phrase += ' ' pos = line.find('.', pos0) if pos == -1: phrase += line[pos0:] break else: # there is at least one period somewhere in the line if last == pos: # current line ends with a period annot[ix].append(phrase + line[pos0:pos + 1]) phrase = '' break elif line[pos + 1] == ' ': # current line contains a period terminating the current annot annot[ix].append(phrase + line[pos0:pos + 1]) phrase = '' pos += 1 else: phrase += line[pos0:pos + 1] pos0 = pos + 1 if len(phrase): annot[ix].append(phrase) for ix in range(len(annot)): # the first annot of each annotation group acts a caption # the tag equals the length of the caption s = qa_util.replace_clasped(annot[ix][0], '<>', '*') md5 = qa_util.get_md5sum(s[0:50]) flag = ' FLAG-BEGL1-' + md5[0:4] + ':CAPT-BEG' flag += 'CMOR ' + annot[ix][0] + 'CAPT-END' annot[ix][0] = flag sz = len(annot[ix]) if sz > 1: annot[ix][0] += 'TXT-BEG' for jx in range(1, sz): if jx > 1: annot[ix][0] += ';' annot[ix][0] += annot[ix][jx] annot[ix][0] += 'TXT-END' del annot[ix][1:] annot[ix][0] += 'FLAG-END' annot[ix][0] = annot[ix][0].replace('"', '\"') for ix in range(len(annot)): print annot[ix][0], return