How to use the mackup.config.ConfigError function in mackup

To help you get started, we’ve selected a few mackup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lra / mackup / tests / config_tests.py View on Github external
def test_config_engine_filesystem_no_path(self):
        with self.assertRaises(ConfigError):
            Config("mackup-engine-file_system-no_path.cfg")
github lra / mackup / tests / config_tests.py View on Github external
def test_config_engine_unknown(self):
        with self.assertRaises(ConfigError):
            Config("mackup-engine-unknown.cfg")
github lra / mackup / mackup / config.py View on Github external
if self.engine == ENGINE_DROPBOX:
            path = get_dropbox_folder_location()
        elif self.engine == ENGINE_GDRIVE:
            path = get_google_drive_folder_location()
        elif self.engine == ENGINE_COPY:
            path = get_copy_folder_location()
        elif self.engine == ENGINE_ICLOUD:
            path = get_icloud_folder_location()
        elif self.engine == ENGINE_BOX:
            path = get_box_folder_location()
        elif self.engine == ENGINE_FS:
            if self._parser.has_option("storage", "path"):
                cfg_path = self._parser.get("storage", "path")
                path = os.path.join(os.environ["HOME"], cfg_path)
            else:
                raise ConfigError(
                    "The required 'path' can't be found while"
                    " the 'file_system' engine is used."
                )

        return str(path)
github lra / mackup / mackup / config.py View on Github external
def _parse_directory(self):
        """
        Parse the storage directory in the config.

        Returns:
            str
        """
        if self._parser.has_option("storage", "directory"):
            directory = self._parser.get("storage", "directory")
            # Don't allow CUSTOM_APPS_DIR as a storage directory
            if directory == CUSTOM_APPS_DIR:
                raise ConfigError(
                    "{} cannot be used as a storage directory.".format(CUSTOM_APPS_DIR)
                )
        else:
            directory = MACKUP_BACKUP_PATH

        return str(directory)
github lra / mackup / mackup / config.py View on Github external
if self._parser.has_option("storage", "engine"):
            engine = str(self._parser.get("storage", "engine"))
        else:
            engine = ENGINE_DROPBOX

        assert isinstance(engine, str)

        if engine not in [
            ENGINE_DROPBOX,
            ENGINE_GDRIVE,
            ENGINE_COPY,
            ENGINE_ICLOUD,
            ENGINE_BOX,
            ENGINE_FS,
        ]:
            raise ConfigError("Unknown storage engine: {}".format(engine))

        return str(engine)