Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_project(self, url: str) -> GitProject:
try:
project = get_project(url=url, custom_instances=self.services)
except OgrException as ex:
msg = f"Authentication for url '{url}' is missing in the config."
logger.warning(msg)
raise PackitConfigException(msg, ex)
return project
def load_packit_yaml(config_file_path: Path) -> Dict:
"""
load provided packit.yaml, raise PackitConfigException if something is wrong
:return: Dict with the file content
"""
try:
return safe_load(config_file_path.read_text())
except Exception as ex:
logger.error(f"Cannot load package config {config_file_path}.")
raise PackitConfigException(f"Cannot load package config: {ex!r}.")
def downstream_package_name(self) -> str:
if not self._downstream_package_name:
raise PackitConfigException("downstream_package_name is not set")
return self._downstream_package_name
if cwd in directories:
directories.remove(cwd)
directories.insert(0, cwd)
if try_local_dir_last:
if cwd in directories:
directories.remove(cwd)
directories.append(cwd)
for config_dir in directories:
for config_file_name in CONFIG_FILE_NAMES:
config_file_name_full = config_dir / config_file_name
if config_file_name_full.is_file():
logger.debug(f"Local package config found: {config_file_name_full}")
return config_file_name_full
raise PackitConfigException("No packit config found.")
self.stderr_output = ensure_str(stderr_output)
class PackitConfigException(PackitException):
pass
class PackitCoprException(PackitException):
pass
class PackitCoprProjectException(PackitCoprException):
pass
class PackitInvalidConfigException(PackitConfigException):
""" provided configuration file is not valid """
@deprecated(reason="Use the PackitFailedToCreateSRPMException instead.")
class FailedCreateSRPM(PackitException):
""" Failed to create SRPM """
class PackitSRPMException(PackitException):
""" Problem with the SRPM """
class PackitSRPMNotFoundException(PackitSRPMException):
""" SRPM created but not found """
f"on ref {ref!r} "
f"of the {project.full_repo_name!r} repository."
)
break
else:
logger.warning(
f"No config file ({CONFIG_FILE_NAMES}) found on ref {ref!r} "
f"of the {project.full_repo_name!r} repository."
)
return None
try:
loaded_config = safe_load(config_file_content)
except Exception as ex:
logger.error(f"Cannot load package config {config_file_name!r}. {ex}")
raise PackitConfigException(
f"Cannot load package config {config_file_name!r}. {ex}"
)
if not spec_file_path:
spec_file_path = get_specfile_path_from_repo(project=project, ref=ref)
return parse_loaded_config(
loaded_config=loaded_config,
config_file_path=config_file_name,
repo_name=project.repo,
spec_file_path=spec_file_path,
)
for config_file_name in CONFIG_FILE_NAMES:
config_file_name_full = config_dir / config_file_name
if config_file_name_full.is_file():
logger.debug(f"Local package config found: {config_file_name_full}")
try:
loaded_config = safe_load(open(config_file_name_full))
except Exception as ex:
logger.error(
f"Cannot load package config '{config_file_name_full}'."
)
raise Exception(f"Cannot load package config: {ex}.")
return parse_loaded_config(loaded_config=loaded_config)
logger.debug(f"The local config file '{config_file_name_full}' not found.")
raise PackitConfigException("No packit config found.")
def _get_project(self, url: str, get_project_kwargs: dict = None) -> GitProject:
get_project_kwargs = get_project_kwargs or {}
try:
project = get_project(
url=url, custom_instances=self.services, **get_project_kwargs
)
except OgrException as ex:
msg = f"Authentication for url {url!r} is missing in the config."
logger.warning(msg)
raise PackitConfigException(msg, ex)
return project
def __eq__(self, other: object):
if not isinstance(other, JobMetadataConfig):
raise PackitConfigException(
"Provided object is not a JobMetadataConfig instance."
)
return (
self.targets == other.targets
and self.timeout == other.timeout
and self.owner == other.owner
and self.project == other.project
and self.dist_git_branches == other.dist_git_branches
and self.branch == other.branch
and self.scratch == other.scratch
and self.list_on_homepage == other.list_on_homepage
and self.preserve_project == other.preserve_project
and self.additional_packages == other.additional_packages
and self.additional_repos == other.additional_repos
)