def create_and_init(self, step_begin, step_end, sysadmin, email, password): log.v('start database create and initialization process.\n') if self.db_type == self.DB_TYPE_SQLITE: db_path = os.path.dirname(self.sqlite_file) if not os.path.exists(db_path): tp_make_dir(db_path) if not os.path.exists(db_path): log.e( 'can not create folder `{}` to store database file.\n'. format(db_path)) return False # 创建一个空数据文件,这样才能进行connect。 if not os.path.exists(self.sqlite_file): try: with open(self.sqlite_file, 'w') as f: pass except: log.e('can not create db file `{}`.\n'.format( self.sqlite_file)) return False if DatabaseInit(self, step_begin, step_end).do_create_and_init(sysadmin, email, password): log.v('database created.\n') self.need_create = False self.load_system_config() return True else: log.e('database create and initialize failed.\n') return False
def create_and_init(self, step_begin, step_end, sysadmin, email, password): log.v('start database create and initialization process.\n') if self.db_type == self.DB_TYPE_SQLITE: db_path = os.path.dirname(self.sqlite_file) if not os.path.exists(db_path): tp_make_dir(db_path) if not os.path.exists(db_path): log.e('can not create folder `{}` to store database file.\n'.format(db_path)) return False # 创建一个空数据文件,这样才能进行connect。 if not os.path.exists(self.sqlite_file): try: with open(self.sqlite_file, 'w') as f: pass except: log.e('can not create db file `{}`.\n'.format(self.sqlite_file)) return False if DatabaseInit(self, step_begin, step_end).do_create_and_init(sysadmin, email, password): log.v('database created.\n') self.need_create = False self.load_system_config() return True else: log.e('database create and initialize failed.\n') return False