Пример #1
0
class SyncItauOptions(threading.Thread):
    """Thread that executes a task every N seconds"""

    def __init__(self):
        """
        :return:
        """
        threading.Thread.__init__(self)
        self._finished = threading.Event()
        self._interval = 3

        driver = RobotRemoteChrome().driver
        self.robot_options = RobotOptions(driver)
        self.robot_bank = RobotBank(driver)
        self.wallet = Wallet()

    def setInterval(self, interval):
        """Set the number of seconds we sleep between executing our task"""
        self._interval = interval

    def shutdown(self):
        """Stop this thread"""
        self._finished.set()

    def run(self):
        """
        :return: sleep for interval or until shutdown
        if self._finished.isSet(): return
        """
        while True:
            # import ipdb; ipdb.set_trace()
            options = self.robot_options.list_contract()
            if options:
                self.wallet.remove_active_old(1)
                self.wallet.save_actives(options)

            if self.robot_bank.is_extract():
                self.robot_bank.get_extract()
                remove_files_path('*.txt')
            # self._finished.wait(self._interval)

    def __hash__(self):
        """
        :return:
        """
        return 0
Пример #2
0
    def __init__(self):
        """
        :return:
        """
        threading.Thread.__init__(self)
        self._finished = threading.Event()
        self._interval = 3

        driver = RobotRemoteChrome().driver
        self.robot_options = RobotOptions(driver)
        self.robot_bank = RobotBank(driver)
        self.wallet = Wallet()