示例#1
0
 def run(self):
     oldlinks = db.get_links()
     oldslivers = db.get_slivers()
     while True:
         log.debug('loop')
         newlinks = db.get_links()
         log.debug(len(oldlinks))
         log.debug(len(newlinks))
         newslivers = db.get_slivers()
         log.debug(len(oldslivers))
         log.debug(len(newslivers))
         if len(newlinks) < len(oldlinks) and len(oldslivers) == len(
                 newslivers):
             log.debug("Rem Links")
             #newlinks = self.objList2dict(newlinks)
             log.debug(newlinks)
             # Find the deleted links
             dellinks = self.diff_list(oldlinks, newlinks)
             #log.debug('Deleted Links')
             #log.debug(dellinks)
             # Delete the removed links
             self.del_links(dellinks)
         elif len(newlinks) > len(oldlinks) and len(oldslivers) == len(
                 newslivers):
             log.debug("Add Links")
             addlinks = self.diff_list(newlinks, oldlinks)
             log.debug(addlinks)
             self.add_links(addlinks)
         # Outside the if to catch also new links
         # not only dropped ones
         oldlinks = newlinks
         oldslivers = newslivers
         time.sleep(period)
示例#2
0
文件: dbpoll.py 项目: emmdim/Pongo
 def run(self):
     oldlinks = db.get_links()
     oldslivers = db.get_slivers()
     while True:
         log.debug('loop')
         newlinks = db.get_links()
         log.debug(len(oldlinks))
         log.debug(len(newlinks))
         newslivers = db.get_slivers()
         log.debug(len(oldslivers))
         log.debug(len(newslivers))
         if len(newlinks) < len(oldlinks) and len(oldslivers) == len(newslivers):
             log.debug("Rem Links")
             #newlinks = self.objList2dict(newlinks)
             log.debug(newlinks)
             # Find the deleted links
             dellinks = self.diff_list(oldlinks,newlinks)
             #log.debug('Deleted Links')
             #log.debug(dellinks)
             # Delete the removed links
             self.del_links(dellinks)
         elif len(newlinks) > len(oldlinks) and len(oldslivers) == len(newslivers):
             log.debug("Add Links")
             addlinks = self.diff_list(newlinks,oldlinks)
             log.debug(addlinks)
             self.add_links(addlinks)
         # Outside the if to catch also new links
         # not only dropped ones
         oldlinks = newlinks
         oldslivers = newslivers
         time.sleep(period)
示例#3
0
 def getLinks(self, predicate, pendings):
     try:
         _lock.acquire()
         print "[%s]get links ..." % predicate.source
         result = db.get_links(predicate.source, pendings)
         return [Link(link[0]) for link in result] if result else []
     finally:
         _lock.release()
示例#4
0
def get_learning_3_markup():
    markup = telebot.types.InlineKeyboardMarkup()
    links = db.get_links()
    #print(links)
    markup.add(telebot.types.InlineKeyboardButton(text='Сайт', url=links[0]))
    markup.add(
        telebot.types.InlineKeyboardButton(text='Мобильное приложение',
                                           url=links[1]))
    return markup
示例#5
0
 def getLinks(self, predicate, pendings):
     try:
         _lock.acquire()
         begin = datetime.datetime.now()
         print "[%s]get links ..." % predicate.source
         result = db.get_links(predicate.source, pendings)
         end  = datetime.datetime.now()
         delta =end - begin
         print "getLinks %s; begin=%s; end=%s; cost=%s" %(predicate.source, begin, end, delta.seconds)
         return [Link(link[0]) for link in result] if result else []
     finally:
         _lock.release()
示例#6
0
 def getLinks(self, predicate, pendings):
     try:
         _lock.acquire()
         begin = datetime.datetime.now()
         print "[%s]get links ..." % predicate.source
         result = db.get_links(predicate.source, pendings)
         end = datetime.datetime.now()
         delta = end - begin
         print "getLinks %s; begin=%s; end=%s; cost=%s" % (
             predicate.source, begin, end, delta.seconds)
         return [Link(link[0]) for link in result] if result else []
     finally:
         _lock.release()
示例#7
0
    def get(self, page):

        # 校验身份
        if self.check_login() == False:
            self.redirect("/login")
            return

            # 处理请求页面
        if 1 == 1:

            if page == "index":
                self.MyRender(admin_dir("%s.html" % page), classify=db.get_classify())

                # 文章管理
            elif page == "articles":
                self.MyRender(admin_dir("%s.html" % page), articles=db.get_article())

                # 更新文章
            elif page == "update":

                id = self.get_argument("id")
                self.MyRender(
                    admin_dir("%s.html" % page), classify=db.get_classify(), article=db.get_atcbyid(id, True), id=id
                )

                # 评论管理
            elif page == "comments":

                self.MyRender(admin_dir("%s.html" % page), comments=db.get_comments())

                # 留言管理
            elif page == "guests":

                self.MyRender(admin_dir("%s.html" % page), guests=db.get_guest())

                # 留言管理
            elif page == "links":

                self.MyRender(admin_dir("%s.html" % page), links=db.get_links())

                # 分类管理

            elif page == "classify":

                self.MyRender(admin_dir("%s.html" % page), classify=db.get_classify())

                # 分类管理

            elif page == "upload":

                self.MyRender(admin_dir("%s.html" % page))

                # 博客配置
            elif page == "options":

                self.MyRender(admin_dir("%s.html" % page), templates=os.listdir(cur_dir() + "templates"))

                # 返回自定义页面
            else:
                # self.MyRender(admin_dir("%s.html" % page))
                self.redirect("/login")
        else:
            self.redirect("/login")