def __init__(self, file_name, is_abs_path=False): if not is_abs_path: file_path = os.path.join(ZSTACK_FILEDB_DIR, file_name) else: file_path = file_name file_dir = os.path.dirname(file_path) if not os.path.exists(file_dir): os.makedirs(file_dir, 0755) #force save for each db operation. self.file_db = pickledb.pickledb(file_path, True)
def setUp(self): while True: self.dbf = 'testdb_%d.json' % int(round(time.time())) if not os.path.exists(self.dbf): break else: continue self.db = pickledb(self.dbf, False) self.teststring = datetime.utcnow() self.testinteger = int(round(time.time()))
def setUp(self): while True: self.dbf='testdb_%d.json' % int(round(time.time())) if not os.path.exists(self.dbf): break else: continue self.db = pickledb(self.dbf, False) self.teststring = datetime.utcnow() self.testinteger = int(round(time.time()))
def get_db_file(self, today=date.today()): # Create today file if it doesn't exists self.current_day = today self.current_day_display.text = self.update_current_day_display() db_filename = "./db/" + str(self.current_day) + "_timelog.db" if not os.path.isfile(db_filename): timelog_file = open(db_filename, 'a') timelog_file.write("{}") timelog_file.close() return pickledb(db_filename, False)
def load(location, option): '''Return a pickledb object. location is the path to the json file.''' return pickledb(location, option)