def close (self) : assert sos.path.exists (self.x_uri), self.x_uri.name db_uri = self.db_uri x_uri = self.x_uri bak = TFL.Filename (".bak", db_uri) with TFL.lock_file (x_uri) : info = self.info self._check_sync (info) with TFL.open_to_replace \ (db_uri, mode = "wb", backup_name = bak) as file: sos.fchmod (file.fileno (), stat.S_IRUSR | stat.S_IWUSR) with contextlib.closing (self.ZF.ZipFile (file, "w")) as zf : for abs, rel in info.FILES (self.x_uri, self.info_uri) : zf.write (abs, rel) sos.rmdir (x_uri, deletefiles = True)
def _handle_auth_mig (self, cao) : try : scope = self._handle_load (cao, journal_dir = None) mig = pyk.pickle.dumps \ (scope.Auth.Account.migration (), pyk.pickle_protocol) with open (cao.mig_auth_file, "wb") as f : sos.fchmod (f.fileno (), stat.S_IRUSR | stat.S_IWUSR) f.write (mig) if cao.verbose : print ("Wrote authorization objects to", cao.mig_auth_file) scope.commit () scope.ems.compact () scope.destroy () except Exception as exc : print ("Saving auth-migration failed with exception\n ", exc)
def close (self) : assert sos.path.exists (self.x_uri.name), self.x_uri.name db_uri = self.db_uri x_name = self.x_uri.name bak = TFL.Filename (".bak", db_uri).name with TFL.lock_file (x_name) : info = self.info self._check_sync (info) with TFL.open_to_replace \ (db_uri.name, mode = "wb", backup_name = bak) as file: sos.fchmod (file.fileno (), stat.S_IRUSR | stat.S_IWUSR) with contextlib.closing (self.ZF.ZipFile (file, "w")) as zf : for abs, rel in info.FILES (self.x_uri, self.info_uri) : zf.write (abs, rel) sos.rmdir (x_name, deletefiles = True)