def cpTables(key, table, table_path, qaOpts, pDir): prj=qaOpts.getOpt('PROJECT_AS') qaHome = qaOpts.getOpt('QA_HOME') pwd= os.getcwd() if len(pDir) == 0: # regular precedence of paths, i.e. highest first if os.path.isfile(table): # absolute path pDir.append(table) else: # local file if os.path.isfile( os.path.join(pwd, table) ): pDir.append(os.path.join(pwd, table)) if qaOpts.isOpt('USE_STRICT'): # USE_STRICT: only the project's default directory pDir.append(os.path.join('tables', 'projects', prj) ) else: pDir.append('tables') pDir.append(os.path.join('tables', prj) ) pDir.append(os.path.join('tables', 'projects') ) pDir.append(os.path.join('tables', 'projects', prj) ) if prj != 'CF': if table[0:3] == 'CF_' or table[0:3] == 'cf-': pDir.append( os.path.join('tables', 'projects', 'CF') ) if key.find('CHECK_LIST') > -1: # concatenate existing files toCat=[] for pD in pDir: t = os.path.join(qaHome, pD, table) if os.path.isfile(t): toCat.append(t) # is any of the files newer than the destination? dest = os.path.join(table_path, table) dest_modTime = qa_util.f_get_mod_time(dest) for f in toCat: if qa_util.f_get_mod_time(f) > dest_modTime: qa_util.cat(toCat, dest) break else: # just copy the file with highest precedence; there should only # be a single one for each kind of table for ix in range(len(pDir)): src = os.path.join(qaHome, pDir[ix], table) if os.path.isfile(src): dest= os.path.join(table_path, table) if qa_util.f_get_mod_time(src) > qa_util.f_get_mod_time(dest): shutil.copyfile(src,dest) break return
def final(): # only the summary of previous runs if not qaOpts.isOpt('NO_SUMMARY') and not qaOpts.isOpt('SHOW'): summary() # remove duplicates for log_fname in g_vars.log_fnames: tmp_log = os.path.join(g_vars.check_logs_path, 'tmp_' + log_fname + '.log') dest_log = os.path.join(g_vars.check_logs_path, log_fname + '.log') if not os.path.isfile(tmp_log): continue # nothing new if os.path.isfile(dest_log): if qaOpts.isOpt('CLEAR_LOGFILE'): ix = g_vars.log_fnames.index(log_fname) fBase = g_vars.clear_fBase[ix] clrdName='cleared_' + log_fname + '.log' clrdFile=os.path.join(g_vars.check_logs_path, clrdName) with open(clrdFile, 'w') as clrd_fd: while True: blk = log.get_next_blk(dest_log, skip_fBase=fBase, skip_prmbl=False) for b in blk: clrd_fd.write(b) else: break if clrd_fd.errors == None: os.rename(clrdFile, dest_log) # append recent results to a logfile qa_util.cat(tmp_log, dest_log, append=True) os.remove(tmp_log) else: # first time that a check was done for this log-file os.rename(tmp_log, dest_log) qa_util.cfg_parser(rawCfgPars, qaOpts.getOpt('CFG_FILE'), final=True) return
def cpTables(key, fTable, tTable, tTable_path, qaConf, prj_from, prj_to, pDir): qaTables = qaConf.getOpt('QA_TABLES') if len(pDir) == 0: if prj_from == prj_to: # regular precedence of paths, i.e. highest first if os.path.isfile(fTable): # absolute path pDir.append(fTable) else: # local file pwd = os.getcwd() if os.path.isfile(os.path.join(pwd, fTable)): pDir.append(os.path.join(pwd, fTable)) if qaConf.isOpt('USE_STRICT') and prj_from == prj_to: # USE_STRICT: only the project's default directory pDir.append(os.path.join('tables', 'projects', prj_from)) else: pDir.append('tables') pDir.append(os.path.join('tables', prj_from)) else: # the only possible place pDir.append(os.path.join('tables', prj_from)) if prj_from == prj_to: if prj_from != 'CF': if fTable[0:3] == 'CF_' or fTable[0:3] == 'cf-': pDir.append(os.path.join('tables', 'projects', 'CF')) if 'CHECK_LIST' in key: # concatenate existing files # is any of the files newer than the destination? dest = os.path.join(tTable_path, tTable) dest_modTime = qa_util.f_get_mod_time(dest) for pD in pDir: src = os.path.join(qaTables, pD, fTable) if os.path.isfile(src): if prj_from == prj_to: dest = os.path.join(tTable_path, tTable) else: dest = os.path.join(tTable_path, fTable) tmp = os.path.join(tTable_path, tTable) try: os.rename(tmp, dest) except: print 'qa_init.cpTables(): could not rename(tmp, dest)' else: # the file of PROJECT_VIRT first qa_util.cat([src], dest) # exchange properties of a corresponding project file qaConf.addOpt(key, fTable) break else: # just copy the file with highest precedence; there should only # be a single one for each kind of table for pD in pDir: src = os.path.join(qaTables, pD, fTable) if os.path.isfile(src): if prj_from == prj_to: dest = os.path.join(tTable_path, tTable) else: dest = os.path.join(tTable_path, fTable) # exchange properties of a corresponding project file qaConf.addOpt(key, fTable) if qa_util.f_get_mod_time(src) > qa_util.f_get_mod_time(dest): shutil.copyfile(src, dest) break return