def histComic(comicURL): webObject = fetchWeb(comicURL,False) cache = Cache() cacheObject = cache.fetchCache(comicURL,None) if not compare(webObject, cacheObject): cache.storeCache(webObject) Scheduler.histComicNotification += 1 notification("Hist: " + comicURL) return None
def newComic(comicURLs): lastChange = None for url in comicURLs: cache = Cache() webObject = fetchWeb(url,False) cacheObject = cache.fetchCache(url,None) if not compare(webObject, cacheObject): cache.storeCache(webObject) lastChange = url if lastChange: Scheduler.newComicNotification += 1 notification("New: " + lastChange) return None
def print_face(img,facess=0): if not facess: faces = CF.face.detect(img) else: faces = facess image = Image.open(img) plt.figure(figsize=(8,8)) ax = plt.imshow(image, alpha=0.8) for i in range(len(faces)): fr = faces[i]["faceRectangle"] #fa = face[0]["faceAttributes"] origin = (fr["left"], fr["top"]) p = patches.Rectangle(origin, fr["width"], fr["height"], fill=False, linewidth=2, color='b') ax.axes.add_patch(p) #plt.text(origin[0], origin[1], "%s, %d"%(fa["gender"].capitalize(), fa["age"]), fontsize=20, weight="bold", va="bottom") _ = plt.axis("off") #plt.show() plt.savefig("show.jpg") notification("入侵警報!!", uploadIMGUR('./show.jpg'))
def post(self, *args, **kwargs): model = CommentModel() id = self.get_argument('article_id', strip=True, default="") model.article_id = id model.name = self.get_argument('inp_name', strip=True, default="") model.contact = self.get_argument('inp_contact', strip=True, default="") model.comment = self.get_argument('inp_comment', strip=True, default="") model.submit_date = date_time() ## 发送钉钉通知 notification(model) ## 添加评论 db_manager.insert_comment(model) self.redirect("article?id=" + id)