def generate_epub(self): text = neattxt.get_neat_txt(self.file_path, self.title, self.txt_folder).split("\n") messager.text_neated.emit() txt2html.format_txt(self.title, self.author, text, self.description, self.txt_folder, self.chr_pattern) self.message.emit('split is done') strucreat.structure(self.description, self.chr_pattern) self.message.emit('structure is done') epubzip.epubzip('epubobject', self.title) arrange.arrange(self.file_path, self.txt_folder, self.epub_folder, self.title) messager.process_message.emit(100) self.message.emit('arrange is done') messager.finished.emit()
def do_draw(self, cr, get_data_fn): if not self.exposed: if self.debug: print("Not exposed") return if self.debug: print("exposed") self.levels, self.pid2node = get_data_fn(self) max_x, max_y, self.levels_x = arrange(self.levels, self.pid2node, self.width, debug=self.debug) old_x, old_y = self.area.get_size_request() if old_x != max_x or old_y != max_y: self.area.set_size_request(max_x, max_y) if len(self.levels) == 0: return # cr.translate (10, 10) layout = PangoCairo.create_layout(cr) desc = Pango.font_description_from_string(self.font) layout.set_font_description(desc) x_offset = 0 text_mid = self.fontHeight >> 1 widths = {} for i, level in enumerate(self.levels): for pid in level: node = self.pid2node[pid] try: vrank, rank, x_offset, y_offset = node.PosInfo except: from trepan.api import debug; debug() # Draw line from process to parent if i > 0: layout.set_text('', -1) ppid = node.PPid parent = self.pid2node[ppid] pp_vrank, pp_i, pp_x, pp_y = parent.PosInfo pp_x += widths[ppid] + self.line_gap cr.move_to(x_offset - self.line_gap, y_offset + text_mid) cr.line_to(pp_x + self.line_gap, pp_y + text_mid) cr.set_source_rgba(0.0, 0.0, 0.0, 0.5) cr.stroke() pass # print(node.Name, node.PosInfo, node.State) PangoCairo.show_layout(cr, layout) cr.move_to(x_offset, y_offset) layout.set_text(node.Name, -1) text_width, text_height = layout.get_pixel_size() widths[pid] = text_width # layout and set process name if node.State[0] == 'R': cr.set_source_rgba(0.0, 1.0, 0.0, 1.0) elif node.State[0] == 'T': cr.set_source_rgba(1.0, 0.0, 0.0, 1.0) else: cr.set_source_rgba(0.0, 0.0, 0.0) if self.debug: print("xy(%d,%d), pid(%ld): %s" % (node.PosInfo[2], node.PosInfo[3], node.Pid, node.Name)) PangoCairo.show_layout(cr, layout) pass return
#print (np.average(ind,weights=hist_full)) #print(np.average((ind-np.ones((256,1))*himn)**2,weights=hist_full))**0.5 #print (np.argmax(hist_full)) ret, t = cv2.threshold(gray, himn - 1.3 * histd, 255, cv2.THRESH_BINARY_INV) #th3 = cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, ret, td = cv2.threshold(gray, himn - 1.3 * histd, 255, cv2.THRESH_BINARY_INV) # cv2.THRESH_BINARY_INV,(11),th) contours, hierarchy = cv2.findContours(td, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) #contours1, hierarchy1 = cv2.findContours(th3,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) #print hierarchy (cont, indi, indl) = arrange(contours, hierarchy) for i in range(len(cont)): cnt = cont[i] #if cv2.contourArea(cnt)>193: #print cv2.contourArea(cnt) x, y, w, h = cv2.boundingRect(cnt) #print x #print y #print w #print h cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 1) im0 = t[y:(y + h), x:(x + w)] black = np.zeros((np.shape(t)))
def hack_maze_path(info ): FlashVars = info maze = lambda: None maze.lmap = [] maze.iMaxSteps = 0 lMaze = FlashVars.split('&') bsolved = False first_path = "" for s in lMaze: if s.startswith("FVterrainString="): strMaze = s[len("FVterrainString="):] if s.startswith("FVinsMin="): maze.iMinSteps = int(s[len("FVinsMin="):]) if s.startswith("FVinsMax="): maze.iMaxSteps = int(s[len("FVinsMax="):]) if s.startswith("FVboardX="): maze.iXBoard = int(s[len("FVboardX="):]) if s.startswith("FVboardY="): maze.iYBoard = int(s[len("FVboardY="):]) if s.startswith("FVlevel="): maze.iLevel= int(s[len("FVlevel="):]) for i in range(maze.iYBoard): s = strMaze[0 : maze.iXBoard] strMaze = strMaze[maze.iXBoard:] if len(s) == maze.iXBoard: maze.lmap.append(s) if len(maze.lmap) != maze.iYBoard: log.info("error, construct maze map failed!") sys.exit(-1) info = "strMaze :" + strMaze + ", maze.iMaxSteps: " + str(maze.iMaxSteps) + \ ", maze.iMinSteps: " + str(maze.iMinSteps) + ", maze.iXBoard: " + \ str(maze.iXBoard) + ", maze.iYBoard: " + str(maze.iYBoard) + \ ", maze.iLevel: " + str(maze.iLevel) log.info('%s', info) print info print maze.lmap for template_len in range(maze.iMinSteps, maze.iMaxSteps + 1): n, lpaths = arrange(template_len) map_t = maze.lmap #for path in lpaths: for path in lpaths: r_num = path.count('R') d_num = path.count('D') x = 0 y = 0 tmp_str = "" i = 0 try: #TODO while is useful ? #while map_t[x][y] != 'X' and x <= (maze.iXBoard -1) and y <= (maze.iYBoard - 1): while x < (maze.iXBoard ) and y < (maze.iYBoard ): if maze.lmap[x][y] != 'X': if path[i % n] == 'R': y += 1 elif path[i % n] == 'D': x += 1 tmp_str += path[i % n] i += 1 else: break ## delete the bad path in the first round #if i <= n: # if map_t[x][y] == 'X': # for t in lpaths: # if t.startswith(tmp_str): # del t if x == maze.iXBoard or y == maze.iYBoard: info = str(n) + " " +path + " is the first good path D: " + tmp_str log.info("%s", info) first_path = path bsolved = True except Exception, err: print str(err) + " i is: " + str(i) + "(" + str(x) + "," + str(y) +")" if bsolved == True: break
from extract import extract from publish import publish import util if __name__ == "__main__": config = configparser.ConfigParser() config.read('config') logfile = util.get_conf_logfile(config, default='log') loglevel = util.get_conf_loglevel(config, default=logging.DEBUG) logger = logging.getLogger(__file__) formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(filename)s:' '%(lineno)d(%(funcName)s) %(msg)s') stream_handler = logging.StreamHandler() stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) file_handler = logging.FileHandler(logfile) file_handler.setFormatter(formatter) logger.addHandler(file_handler) logger.setLevel(loglevel) logger.info('Starting win10_lockscreen_extract...') extract(config) arrange(config) publish(config)