def _cmd(self, recipe=None, options=None, env_var=None, output_filter=None): cmd = "" if env_var is not None: cmd += env_var + " " cmd += "bitbake " if options is not None: cmd += options + " " if recipe is not None: cmd += recipe if output_filter is not None: cmd += ' | grep ' + output_filter os.chdir(self.build_dir) try: stdout, stderr = bb.process.run(cmd) except bb.process.ExecutionError as e: D("%s returned:\n%s" % (cmd, e.__str__())) if self.log_dir is not None and os.path.exists(self.log_dir): with open(os.path.join(self.log_dir, BITBAKE_ERROR_LOG), "a+") as log: log.write(e.stdout) raise Error("\'" + cmd + "\' failed", e.stdout, e.stderr) return stdout
def diff(self): rev_initial = self.revs[0] rev_final = self.revs[-1] try: cmd = "buildhistory-diff -p %s %s %s" % (self.buildhistory_dir, rev_initial, rev_final) stdout, stderr = bb.process.run(cmd) if stdout and os.path.exists(self.workdir): with open(os.path.join(self.workdir, "buildhistory-diff.txt"), "w+") as log: log.write(stdout) cmd_full = "buildhistory-diff -a -p %s %s %s" % (self.buildhistory_dir, rev_initial, rev_final) stdout, stderr = bb.process.run(cmd_full) if stdout and os.path.exists(self.workdir): with open(os.path.join(self.workdir, "buildhistory-diff-full.txt"), "w+") as log: log.write(stdout) except bb.process.ExecutionError as e: W( "%s: Buildhistory checking fails\n%s" % (self.pn, e.stdout))
files = (input_plus, input_minus) strands = ('+', '-') log = open('%s/%s.log' % (out_dir, name), 'w') for i in range(2): input_file = files[i] strand = strands[i] print("Processing %s strand" % strand) #block_length = 1e5 blocks_pos = get_block_position(input_file, window, block_length) block_input_list = [] for bp in blocks_pos: baseName = '%s.%s_%s_%s' % (name, bp[3], strand, bp[0]) #if bp[4] > bp[5]: # print(bp) log.write('Blocks:{}\n'.format('\t'.join(str(e) for e in bp))) #print('%s\t%d\t%d'%(baseName,bp[4],bp[5])) block_input_list.append([ baseName, model, out_dir, rst, window, keep_temp, threshold, penality, DB_file, input_file, strand, depth, bp ]) print("Predicting results ...") pred_start_time = datetime.datetime.now() with Pool(thread) as p: #p.map(run_single_block,block_input_list) time_lists = p.map(run_single_block, block_input_list) #p.close() #p.terminate() #p.join() for i, input_list in enumerate(block_input_list):
def log(message): """ ログファイルにメッセージを追加する @param string message """ logging.write(message)
def main(out_dir, input_file, input_plus, input_minus, fa_file, keep_temp, window, name, model, rst, threshold, penality, DB_file, depth, thread): if (out_dir[-1] == '/'): out_dir = out_dir[0:-1] if not os.path.exists(out_dir): os.makedirs(out_dir) out_dir = out_dir + '/' + name if not os.path.exists(out_dir): os.makedirs(out_dir) if input_file is not None: input_plus = input_file input_minus = input_file files = (input_plus, input_minus) strands = ('+', '-') log = open('%s/%s.log' % (out_dir, name), 'w') for i in range(2): input_file = files[i] strand = strands[i] print("Processing %s strand" % strand) blocks = Get_block_position(out_dir, input_file, strand, window, 1e6) block_input_list = [] for chromosome, strand, block_num, start, end in blocks: baseName = '%s.%s_%s_%s' % (name, chromosome, strand, block_num) print('%s\t%d\t%d' % (baseName, start, end)) block_input_list.append([ baseName, model, out_dir, rst, window, keep_temp, threshold, penality, DB_file, input_file, chromosome, strand, fa_file, depth, start, end ]) print("Predicting results ...") pred_start_time = datetime.datetime.now() #block_out_indic = [] with Pool(thread) as p: #p.map(run_single_block,block_input_list) time_lists = p.map(run_single_block, block_input_list) #p.close() p.terminate() p.join() for i, input_list in enumerate(block_input_list): baseName = input_list[0] gw_time, ev_time, ps_time = time_lists[i] log.write('%s\t%s\t%s\t%s\n' % (baseName, str(gw_time), str(ev_time), str(ps_time))) # print('%s\t%s\t%s\t%s\n'%(baseName,str(gw_time),str(ev_time),str(ps_time))) pred_end_time = datetime.datetime.now() print("Prediction used time: {}".format(pred_end_time - pred_start_time)) log.close() out_file = '%s/%s.predicted.txt' % (out_dir, name) ww = open(out_file, 'w') if (DB_file is not None): ww.write('predicted_pasid\tdb_pasid\tdb_diff\tscore\n') else: ww.write('predicted_pasid\tscore\n') ww.close() os.system('cat %s/maxSum/*bidirection* >>%s' % (out_dir, out_file)) if (keep_temp != 'yes'): os.system('rm -rf %s/predict %s/maxSum' % (out_dir, out_dir)) print("Job Done!")
#block_out_indic = [] with Pool(thread) as p: #p.map(run_single_block,block_input_list) time_lists = p.map(run_single_block,block_input_list) #p.close() p.terminate() p.join() for i,input_list in enumerate(block_input_list): baseName = input_list[0] gw_time,ev_time,ps_time = time_lists[i] log.write('%s\t%s\t%s\t%s\n'%(baseName,str(gw_time),str(ev_time),str(ps_time))) # print('%s\t%s\t%s\t%s\n'%(baseName,str(gw_time),str(ev_time),str(ps_time))) pred_end_time = datetime.datetime.now() print("Prediction used time: {}".format(pred_end_time - pred_start_time)) log.close() out_file = '%s/%s.predicted.txt' %(out_dir,name) ww = open(out_file,'w') if(DB_file is not None): ww.write('predicted_pasid\tdb_pasid\tdb_diff\tscore\n') else: ww.write('predicted_pasid\tscore\n') ww.close() os.system('cat %s/maxSum/*bidirection* >>%s'%(out_dir,out_file)) if(keep_temp != 'yes'):
# #cv2.imshow('validation', frame[y:y+h,x:x+w]) if (person != ""): person_id = person["personId"] confidence_id = person["confidence"] name = csclub_group.persons[person_id]['name'] studentId = csclub_group.persons[person_id]['studentId'] email = csclub_group.persons[person_id]['email'] login_timestamp = dt.datetime.utcnow().strftime( "%b-%d:%H:%M:%S") log_string = "\t".join( [login_timestamp, name, studentId, gender, smile]) print("[Logging] -- {}".format(log_string)) log.write(log_string + "\n") cv2.rectangle(frame, (0, VIDEO_HEIGHT // 3), (VIDEO_WIDTH, (VIDEO_HEIGHT * 2) // 3), (0, 0, 0), -1) cv2.putText(frame, "[SUCCESS] <CompSciClub>", (25, (VIDEO_HEIGHT // 2) - 35), font, 1, (0, 255, 0), 1) cv2.putText(frame, "WELCOME {}!!".format(name), (25, (VIDEO_HEIGHT // 2)), font, 1, (255, 255, 255), 2) cv2.putText( frame, "Age-[{}] Gender-[{}] Smile:)-[{}]".format( age, gender, smile), (25, (VIDEO_HEIGHT // 2) + 35), font, 0.8, (255, 255, 255), 1) #cv2.putText(frame, "Email: {}".format(email) , (x,y+60), font, 0.25, (255,255,255), 1)
#! python3 import subprocess, sys import logging as log #subprocess.Popen(['/bin/sh', 'echo', 'Hello Python!']) subprocess.Popen(['start', 'hello.txt'], shell=True) # run other python script subprocess.Popen([sys.executable, 'print("hello")']) with subprocess.Popen(["ifconfig"]) as proc: log.write(proc.stdout.read())