def main(server, itv=5, ctl=CTL, port=8091, path="/pools/default", dbhost="127.0.0.1", dbslow="slow", dbfast="fast"): vc.store = vc.SerieslyStore(dbhost, dbslow, dbfast) vc.tbl.set_ftr("Last Update: %time") if not ctl["bg"]: pt.enter_fullscreen() mc_store = vc.SerieslyStore(dbhost, dbslow, dbfast) mc_proc = multiprocessing.Process(target=vc.mc_worker, args=(vc.mc_jobs, vc.mc_stats, ctl, mc_store, itv)) mc_proc.daemon = True mc_proc.start() visit_entry_func = VISIT_ENTRY_FUNCS.copy() visit_entry_func["collect_mc_stats"] = vc.collect_mc_stats while ctl["run_ok"]: vc.store.clear() visit(server, port, path, {"fast": vc.store_fast, "slow": vc.store_slow}, {"url_before": vc.url_before, "url_after": vc.url_after}, retrieve_funcs={"retrieve_data": vc.retrieve_data, "retrieve_meta": retrieve_meta}, entry_funcs=visit_entry_func, ctl=ctl) vc.store.persist() if not ctl["bg"]: pt.paint(vc.tbl) logging.info("sleep for %s seconds" % itv) time.sleep(itv)
def main(server, itv=5, ctl=CTL, port=8091, path="/pools/default", dbhost="127.0.0.1", dbslow="slow", dbfast="fast"): vc.store = vc.SerieslyStore(dbhost, dbslow, dbfast) vc.tbl.set_ftr("Last Update: %time") if not ctl["bg"]: pt.enter_fullscreen() mc_store = vc.SerieslyStore(dbhost, dbslow, dbfast) mc_proc = multiprocessing.Process(target=vc.mc_worker, args=(vc.mc_jobs, vc.mc_stats, ctl, mc_store, itv)) mc_proc.daemon = True mc_proc.start() visit_entry_func = VISIT_ENTRY_FUNCS.copy() visit_entry_func["collect_mc_stats"] = vc.collect_mc_stats while ctl["run_ok"]: vc.store.clear() visit(server, port, path, { "fast": vc.store_fast, "slow": vc.store_slow }, { "url_before": vc.url_before, "url_after": vc.url_after }, retrieve_funcs={ "retrieve_data": vc.retrieve_data, "retrieve_meta": retrieve_meta }, entry_funcs=visit_entry_func, ctl=ctl) vc.store.persist() if not ctl["bg"]: pt.paint(vc.tbl) logging.info("sleep for %s seconds" % itv) time.sleep(itv)
def mylist(): fs = request.files["genes"] myindex = int(request.form.get("index")) print(myindex) name = fs.filename fs.save(fs.filename) fs = open(fs.filename) count = len(fs.readlines()) - 1 matrix = [[0 for i in range(3)] for i in range(count)] out_matrix = [[0 for i in range(4)] for i in range(count + 1)] fin = open(name) str1 = fin.readline() for i in range(count): str1 = fin.readline() matrix[i][0] = str1.split()[0] matrix[i][1] = str1.split()[1] matrix[i][2] = str1.split()[2] if (myindex == 1): paint.paint(matrix) out_matrix[0][0] = "gene_id " out_matrix[0][1] = "control_sample " out_matrix[0][2] = "treat_sample " out_matrix[0][3] = "log_2[FC]" for i in range(count): v1 = float(matrix[i][1]) v2 = float(matrix[i][2]) for j in range(3): out_matrix[i + 1][j] = matrix[i][j] if (v1 == 0 or v2 == 0): out_matrix[i + 1][3] = "null" else: out_matrix[i + 1][3] = math.log(v2 / v1, 2) print(matrix[0][0]) print(out_matrix[0][1]) if (count > 100): return_matrix = [[0 for i in range(4)] for i in range(100)] for i in range(100): for j in range(4): return_matrix[i][j] = out_matrix[(myindex - 1) * 100 + i][j] else: return_matrix = [[0 for i in range(4)] for i in range(10)] for i in range(10): for j in range(4): return_matrix[i][j] = out_matrix[(myindex - 1) * 10 + i][j] return jsonify(return_matrix)
def showboard(brd, R, C, gap, pause): pretty = '\n ' if C <= 26: for c in range(C): # columns pretty += gap + paint(chr(ord('a') + c), PTS) else: gap = '' pretty += '\n' for j in range(R): # rows if j < 10: pretty += ' ' pretty += gap + paint(str(j), PTS) + ' ' for k in range(C): # columns pretty += gap + paint([brd[point(j, k, C)]], PTS) if j == R - 1: # in last row, put last guard pretty += gap + paint(brd[R * C], PTS) pretty += '\n' print(pretty) sleep(pause)
def main(): print_instructions = paint() gcode_rectangles = convert_rectangles(print_instructions["rectangles"]) gcode = [*gcode_rectangles] wait_for_arduino() for instruction in gcode: send_to_arduino(instruction) print(receive_from_arduino())
def showboard(board, row, C, gap, pause): # add numeric row indices, alphabetic column indices pretty = '\n ' if C <= 26: for c in range(C): # columns pretty += gap + paint(chr(ord('a')+c), PTS) else: gap = '' pretty += '\n' for j in range(row): # rows if j < 10: pretty += ' ' pretty += gap + paint(str(j), PTS) + ' ' for k in range(C): # columns pretty += gap + paint([board[point(j, k, C)]], PTS) if j == row-1: # in last row, put last guard pretty += gap + paint(board[row*C], PTS) pretty += '\n' print(pretty) sleep(pause)
def check_static_func(self): self.widget.setVisible(False) self.widget_2.setVisible(False) self.widget_3.setVisible(True) self.widget_5.setVisible(True) self.widget_4.setVisible(False) static = paint() print("num", self.result_0_num) try: png = static.main(self.result_0_num, self.show_list) except: print("图片生成失败") self.widget_3.setStyleSheet("border-image: url(./01.png);\n") self.widget_5.setStyleSheet("border-image: url(./02.png);\n")
def get_stroke_list(R, use_salience=False): paint.pave_the_canvas(width, height) canvas = paint.get_current_canvas(width, height) if use_salience: salience = reference_image.get_salient_reference(src_img) ref = src_img else: salience = None ref = reference_image.get_gaussian_reference(src_img, R) stroke_list_tmp = paint.paint(ref, canvas, radius=R, painting_area=salience) #stroke_list_tmp = paint.sort_stroke(stroke_list_tmp) stroke_list.extend(stroke_list_tmp) glutPostRedisplay()
def main(): try: if len(sys.argv) <= 1: raise FileNotSpecified("No input file specified") elif len(sys.argv) <= 2: raise FileNotSpecified("No output file specified") image_name = sys.argv[1] output_name = sys.argv[2] # read in the image image = cv2.imread(image_name, cv2.IMREAD_COLOR) # create the painting painted_image = paint(image, CURVED_STROKE) # write image to disk cv2.imwrite(output_name, painted_image) except FileNotSpecified: print "Error: Either input or output file not specified" sys.exit()
pressed_fields = selected_fields.copy() pressed_space = not pressed_space elif field[selected_fields[0]][ selected_fields[1]] == 0 and pressed_space: # distance check if abs(selected_fields[0] - pressed_fields[0]) + abs( selected_fields[1] - pressed_fields[1]) == 1: field[selected_fields[0]][selected_fields[1]], field[pressed_fields[0]][pressed_fields[1]] = \ field[pressed_fields[0]][pressed_fields[1]], field[selected_fields[0]][ selected_fields[1]] pressed_space = not pressed_space # drawing scene scene.blit(background, (0, 0)) paint(field, scene, sprites, selected_fields, pressed_fields, pressed_space) else: # exit check for event in pygame.event.get(): if event.type == pygame.QUIT or event.type == pygame.KEYDOWN: pygame.quit() exit() # end_game text font = pygame.font.Font(None, 36) text_end_game = font.render("You win.", 1, (0, 0, 0), (255, 255, 255)) place_for_text = text_end_game.get_rect(center=(224, 150)) text_end_game_2 = font.render("Press any button.", 1, (0, 0, 0), (255, 255, 255)) place_for_text2 = text_end_game_2.get_rect(center=(224, 180))