def main(_): filename = args.filename flag = 0 ex = ExtractMacros(filename) files = ex.extract('transfer_output_files')['transfer_output_files'] for _ in files: if os.path.exists('./' + _) != True: flag = 1 if flag == 0: mf = ModifyNode(filename) mf.change_to_noop() else: print 'Not all output exist, no change'
def detect_status(self, macro, status): # check whether a macro's value matches the giving status. if self.filename == None: print 'No target' return 1 em = ExtractMacros(self.filename) temp = em.extract(macro) #every value is warp by a list if temp.has_key(macro): if [status] == temp[macro]: return 0 else: return 1 else: return 1
def convert_dataflow(jobs): dataflow = [] for j in jobs: temp = {'Input':[],'Output':[]} #get filepath name = j.items()[0][0] path = j.items()[0][1] em = ExtractMacros(path) result = em.extract('input','transfer_input_files','executable','transfer_output_files') # make input if result.has_key('input'): temp['Input'] += result['input'] if result.has_key('transfer_input_files'): temp['Input'] += result['transfer_input_files'] if result.has_key('executable'): temp['Input'] += result['executable'] temp['T'] = name if result.has_key('transfer_output_files'): temp['Output'] = result['transfer_output_files'] dataflow.append(temp) return dataflow
def main(_): filename = args.filename flag = 0 if filename == None: print 'No target' return 1 #get the input and output sandbox ex = ExtractMacros(filename) #Processing output sandbox output = ex.extract('transfer_output_files')['transfer_output_files'] oflag = 0 otimes = [] for _ in output: # check all output files exist if os.path.exists('./' + _) != True: oflag = 1 else: # extract modified time oinfo = os.stat('./' + _) otimes.append(oinfo.st_mtime) if otimes != []: #the oldest output file otime = sorted(otimes)[0] else: otime = -1 #Processing input sandbox input = ex.extract('input')['input']+ex.extract('transfer_input_files')['transfer_input_files']+ex.extract('executable')['executable'] iflag = 0 itimes = [] for _ in input: # check all output files exist if os.path.exists('./' + _) != True: print _,' not exists' iflag = 1 else: # extract modified time info = os.stat('./' + _) itimes.append(info.st_mtime) #Get the newest time if itimes != []: #the newest input file itime = sorted(itimes)[-1] else: itime = -1 #Rule mn = ModifyNode(filename) if mn.detect_status("noop_job","True"): # Current status is OP if iflag == 0: if oflag == 0: if itime < otime: mn.change_to_noop() else: print r'No change(new input file)' else: print r'No change (lack output file)' else: mn.change_to_noop() else: # current status is NOOP if iflag == 0: if oflag == 0: if itime < otime: print 'No change(no new inputfile)' else: mn.reverse_noop() else: mn.reverse_noop() else: print r'No change(lack input file)'