Пример #1
0
    def export_db_to_img(db_file, img_dir, frame_no = None):
        DAY_MIN = 24 * 60 * 60

        db = logdb.LogDb(db_file)
        db.connect()
        db.create_cursor()

        db_start_time, db_end_time = PriceBoardDB.start_time(db)

        print('time->', db_end_time)

        start_time = (int(db_start_time / (DAY_MIN)) + 1) * DAY_MIN
        end_time = (int(db_end_time / (DAY_MIN))) * DAY_MIN

        time = start_time

        print('time->', time)

        while time < end_time:
            print('db->', db)
            result = PriceBoardDB.save_to_img(time, img_dir, db, frame_no)
            time += 1

            if frame_no is not None and result:
                frame_no += 1

        db.close()
Пример #2
0
    def export_board_to_blob(start_time=None, end_time=None, db_object=None, root_dir='/tmp'):
        DAY_MIN = 24 * 60 * 60

        if db_object is None:
            db = logdb.LogDb('/tmp/bitlog.db')
            db.connect()
            db.create_cursor()
        else:
            db = db_object

        if start_time is None or end_time is None:
            db_start_time, db_end_time = PriceBoardDB.start_time(db)

            start_time = (int(db_start_time / (DAY_MIN)) + 1) * DAY_MIN
            end_time = (int(db_end_time / (DAY_MIN))) * DAY_MIN

            print(start_time, end_time, db_start_time, db_end_time)

            if not (db_start_time < start_time and end_time < db_end_time):
                print('wrong data')
                # todo do something
                return None

        PriceBoardDB.export_db_to_blob(db, start_time, end_time, root_dir)

        if db_object is None:
            db.close()
Пример #3
0
    def load_from_db(time, db_name = "/tmp/bitlog.db"):
        db = logdb.LogDb(db_name)
        db.connect()
        db.create_cursor()

        board = PriceBoardDB.load_from_connected_db(time, db)

        db.close()
        return board
Пример #4
0
    def start_time(db=None):
        if db is None:
            db = logdb.LogDb('/tmp/bitlog.db')
            db.connect()
            db.create_cursor()

        start_time, end_time = db.get_db_info()

        return start_time, end_time
Пример #5
0
 def open_db(self, db_name):
     self.db = logdb.LogDb(db_name)
     self.db.connect()
     self.db.create_cursor()
     self.db_start_time, self.db_end_time = Generator.start_time(self.db)
     print('OPENDB->', db_name, self.db_start_time, self.db_end_time)