def printMsg(self, properties, filename): log.debug("Trying to call printMsg...[%s], [%s]" %(properties['html'], filename)) print_colored_cyan = lambda x: cprint(x, 'cyan') print_colored_magenta = lambda x: cprint(x, 'magenta') print_colored_cyan("Downloading: " + properties['html']) print_colored_magenta("\n\t->" + self.path + filename) print_colored_magenta("\t->" + "Resolution:" + properties['Resolution']) print_colored_magenta("\t->" + "Size:" + properties['Size']) print_colored_magenta("\t->" + "Views:" + properties['Views']) print_colored_magenta("\t->" + "Tags:" + str(properties['Tags'])) print_colored_magenta("\t->" + "Added:" + str(properties['Added']))
def run(self): while True: try: print_colored_green = lambda x: cprint(x, 'green') entry = self.log_queue.get() logger.debug("Trying to Log: %s" % entry) log = open(self.logpath, 'a+' ) log.write(entry + "\n") log.close() print_colored_green("Logged: " + entry) self.log_queue.task_done() except: logger.error("Error in the logger")
def run(self): while self.signal: try: site = self.site_queue.get() log.debug("Getting Site... %s" % site) r = requests.get(site) match = re.findall ( self.pattern, r.text) if match: for m in match: link = self.wallsite + m self.sublink_queue.put( link ) self.site_queue.task_done() except: print_colored_red = lambda x: cprint (x, 'red') print_colored_red('Unable to connect to '+ site) self.site_queue.task_done()
def run(self): while self.signal: link = self.in_queue.get() log.debug("Getting Sublink... %s" % link) r = requests.get(link) properties = self.extractProperties(r) self.out_queue.put(properties) try: print_colored_yellow = lambda x: cprint(x, 'yellow') print_colored_yellow("Extracted Link: " + properties['html']) #match = re.search(self.pattern, r.text) #if match: # self.out_queue.put(match.group(1)) # print_colored_yellow = lambda x: cprint(x, 'yellow') # print_colored_yellow("Extracted Link: " + match.group(1)) self.in_queue.task_done() except Exception as e: log.error("There was an error in getting the sublink: %s"%e) break