def _backupPreferences(self): preferencesFileName: str = Preferences.getPreferencesLocation() source: str = preferencesFileName target: str = f"{preferencesFileName}{TestPreferences.BACKUP_SUFFIX}" if osPath.exists(source): try: copyfile(source, target) except IOError as e: self.logger.error(f'Unable to copy file. {e}')
def __init__(self): self._setupSystemLogging() self.logger: Logger = getLogger(__name__) Preferences.determinePreferencesLocation() configFile: Path = Path(Preferences.getPreferencesLocation()) # # Will create a default one if necessary # if configFile.exists() is False: self._preferences = Preferences()
def _restoreBackup(self): preferencesFileName: str = Preferences.getPreferencesLocation() source: str = f"{preferencesFileName}{TestPreferences.BACKUP_SUFFIX}" target: str = preferencesFileName if osPath.exists(source): try: copyfile(source, target) except IOError as e: self.logger.error(f"Unable to copy file. {e}") osRemove(source) else: osRemove(target)