Exemplo n.º 1
0
 def schedule_getter(self, cycle=GETTER_CYCLE):
     getter = Getter()
     while True:
         logging().info("开始抓取代理")
         print("开始抓取代理")
         # 抓取器开始运行
         getter.run()
         time.sleep(cycle)
Exemplo n.º 2
0
 def schedule_getter(self, cycle=GETTER_CYCLE):
     """
     定时获取代理
     """
     getter = Getter()
     while True:
         print('开始抓取代理')
         getter.run()
         time.sleep(cycle)
Exemplo n.º 3
0
 def __init__(self, surface, config, ledCircle):
     UIElement.__init__(self, surface)
     api_ip = config['TEST']['api_ip']
     api_port = config['TEST']['api_port']
     username = config['TEST']['username']
     password = config['TEST']['password']
     self.state = InboxState.WAITING
     self.getter = Getter(api_ip, api_port, username, password)
     self.getter.start()
     self.ledCircle = ledCircle
     pass
Exemplo n.º 4
0
 def schedule_getter(self, cycle=GETTER_CYCLE):
     '''
     定时获取代理
     :param cycle: 定时周期
     :return:
     '''
     getter = Getter()
     while True:
         log_action('开始抓取代理')
         getter.run()
         time.sleep(cycle)
Exemplo n.º 5
0
 def schedule_getter(self, cycle=GETTER_CYLE):
     """
     定时获取代理
     :param cycle:
     :return:
     """
     getter = Getter()
     while True:
         print("开始抓取代理")
         getter.run()
         time.sleep(cycle)
Exemplo n.º 6
0
class Inbox(UIElement):
    def __init__(self, surface, config, ledCircle):
        UIElement.__init__(self, surface)
        api_ip = config['TEST']['api_ip']
        api_port = config['TEST']['api_port']
        username = config['TEST']['username']
        password = config['TEST']['password']
        self.state = InboxState.WAITING
        self.getter = Getter(api_ip, api_port, username, password)
        self.getter.start()
        self.ledCircle = ledCircle
        pass

    def update_inbox(self, force_update=False):
        #TODO : update new getter
        self.inbox = self.getter.get_inbox(force_update=force_update)

    def mouse_down(self, x, y):
        UIElement.mouse_down(self, x, y)
        if self.state == InboxState.WAITING:
            if len(self.inbox) > 0:
                self.state = InboxState.READING
                self.pop_message()
        elif self.state == InboxState.READING:
            if len(self.inbox) > 0:
                self.pop_message()
            else:
                self.state = InboxState.WAITING

    def pop_message(self):
        self.message = self.getter.pop_message()
        self.update_inbox(force_update=True)
        return self.message

    def update(self):
        UIElement.update(self)
        self.update_inbox()

    def draw(self):
        UIElement.draw(self)
        if self.state == InboxState.WAITING:
            if len(self.inbox) > 0:
                message = 'Vous avez %s nouveaux messages' % str(
                    len(self.inbox))
                self.ledCircle.animation = self.inbox[0]['animation']
                self.drawText(message, (255, 255, 255), self.font)
            else:
                self.ledCircle.animation = 'off'
        elif self.state == InboxState.READING:
            message = self.message['content'] + '(' + str(len(
                self.inbox)) + ')'
            self.drawText(message, (255, 255, 255), self.font)
Exemplo n.º 7
0
 def test_integration(self):
     c = Client(api_ip, api_port)
     c.login(username, password)
     c.send_message(username, lorem.sentence())
     g = Getter(api_ip, api_port, username, password)
     g.start()
     time.sleep(g.get_period())
     self.assertGreater(len(g.get_inbox()), 0)
Exemplo n.º 8
0
    def __init__(self,
                 what_to_grade: WhatToGrade = None,
                 who_to_grade: WhoToGrade = None,
                 getter: Getter = None,
                 tester: Tester = None,
                 recorder: Recorder = None):
        if not what_to_grade:
            what_to_grade = WhatToGrade()
        if not who_to_grade:
            who_to_grade = WhoToGrade()
        if not getter:
            getter = Getter(what_to_grade, who_to_grade)
        if not tester:
            tester = Tester(what_to_grade, who_to_grade)
        if not recorder:
            recorder = Recorder(what_to_grade, who_to_grade)

        self.what_to_grade = what_to_grade
        self.who_to_grade = who_to_grade
        self.getter = getter
        self.tester = tester
        self.recorder = recorder
Exemplo n.º 9
0
 def control_get(self):
     getter = Getter()
     while True:
         getter.run()
         time.sleep(20)
Exemplo n.º 10
0
 def schedule_getter(self, cycle=20):
     getter = Getter()
     while True:
         print('获取IP开始')
         getter.run()
         time.sleep(cycle)