예제 #1
0
    def check(self):
        if self._pipe_to_interbank.status():
            bid, offer = self.parser(self._pipe_to_interbank.data['content'])

            self._struct.time = datetime.now()
            self._struct.bid.main = bid[0]
            self._struct.bid.diff = bid[1]
            self._struct.offer.main = offer[0]
            self._struct.offer.diff = offer[1]

            self._insert_obj({
                'time': self._struct.time,
                'bid_main': self._struct.bid.main,
                'bid_diff': self._struct.bid.diff,
                'offer_main': self._struct.offer.main,
                'offer_diff': self._struct.offer.diff
            })

            log.info(self._struct)
            # log.info(self._get_all_objects())

        else:
            for i, v in self._pipe_to_interbank.errors.items():
                log.debug(i)
                log.debug(v)

        self._add_mark()
예제 #2
0
    def check(self):
        if self._pipe_to_nbu.status():
            nbu_week, bid_offer, tbody = self.parser(
                self._pipe_to_nbu.data['content'])

            self._struct.time = datetime.now()
            self._struct.official.main = bid_offer[0]
            self._struct.official.diff = bid_offer[1]
            self._struct.week = nbu_week.text
            self._struct.date = tbody.small.text

            self._insert_obj({
                'time': self._struct.time,
                'official_main': self._struct.official.main,
                'official_diff': self._struct.official.diff,
                'week': self._struct.week,
                'date': self._struct.date
            })

            log.info(self._struct)
            # log.info(self._get_all_objects())

        else:
            for i, v in self._pipe_to_nbu.errors.items():
                log.debug(i)
                log.debug(v)

        self._add_mark()
예제 #3
0
    def run(self):
        while self.__run:
            log.debug(self.__current_mark)
            sleep(self.__kvant)
            for callback in self.__clock_face[self.__current_mark]:
                log.info(callback)
                callback()

            self.__clock_face[self.__current_mark] = []
            if self.__current_mark == 59:
                self.__current_mark = 0
            else:
                self.__current_mark += 1
예제 #4
0
    def _insert_obj(cls, data):
        log.debug('\n')
        log.debug(cls.collection_name)
        log.debug(data)

        data = cls._validate_incoming_data(data)
        result = cls.collection.insert_one(data)
        data['_id'] = result.inserted_id
        return data
예제 #5
0
    def __init__(self):
        self.__chronometer = Chronometer()
        self.__chronometer.start()

        self.__climate = Climate(chrono=self.__chronometer)
        self.__door = Door(chrono=self.__chronometer)
        self.__gas = Gas(chrono=self.__chronometer)
        self.__leak = Leak(chrono=self.__chronometer)
        self.__pir = Pir(chrono=self.__chronometer)
        self.__plug = Plug(chrono=self.__chronometer)
        self.__relay = Relay(chrono=self.__chronometer)
        self.__smoke = Smoke(chrono=self.__chronometer)
        self.__valve = Valve(chrono=self.__chronometer)
        self.__valve3d = Valve3D(chrono=self.__chronometer)

        log.debug(self.__valve.path_to_deb())
        log.debug(self.__valve.path_to_hex())
        log.debug(os.stat(self.__valve.path_to_hex()))
예제 #6
0
                self.__data = {
                    'headers': response.headers,
                    'status_code': response.status_code,
                    'url': response.url,
                    'reason': response.reason,
                    'request': response.request,
                    'content': response.content,
                    'json': response.json,
                    'history': response.history,
                    'cookies': response.cookies,
                    'elapsed': response.elapsed,
                    'links': response.links,
                    'raw': response.raw
                }
                return True


if __name__ == '__main__':
    urls = ['https://google.com', 'https://google.coms']
    for url in urls:
        url_obj = URL(url)
        log.debug(url_obj)
        if url_obj.status():
            for i, v in url_obj.data.items():
                log.debug(i)
                log.debug(v)
        else:
            for i, v in url_obj.errors.items():
                log.debug(i)
                log.debug(v)