summaryrefslogtreecommitdiff
path: root/src/buildstream/_context.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildstream/_context.py')
-rw-r--r--src/buildstream/_context.py61
1 files changed, 12 insertions, 49 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index 17fe691d4..c550a1e62 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -215,9 +215,7 @@ class Context:
# a $XDG_CONFIG_HOME/buildstream.conf file
#
if not config:
- default_config = os.path.join(
- os.environ["XDG_CONFIG_HOME"], "buildstream.conf"
- )
+ default_config = os.path.join(os.environ["XDG_CONFIG_HOME"], "buildstream.conf")
if os.path.exists(default_config):
config = default_config
@@ -232,9 +230,7 @@ class Context:
# Give obsoletion warnings
if "builddir" in defaults:
- raise LoadError(
- "builddir is obsolete, use cachedir", LoadErrorReason.INVALID_DATA
- )
+ raise LoadError("builddir is obsolete, use cachedir", LoadErrorReason.INVALID_DATA)
if "artifactdir" in defaults:
raise LoadError("artifactdir is obsolete", LoadErrorReason.INVALID_DATA)
@@ -271,12 +267,9 @@ class Context:
# Relative paths don't make sense in user configuration. The exception is
# workspacedir where `.` is useful as it will be combined with the name
# specified on the command line.
- if not os.path.isabs(path) and not (
- directory == "workspacedir" and path == "."
- ):
+ if not os.path.isabs(path) and not (directory == "workspacedir" and path == "."):
raise LoadError(
- "{} must be an absolute path".format(directory),
- LoadErrorReason.INVALID_DATA,
+ "{} must be an absolute path".format(directory), LoadErrorReason.INVALID_DATA,
)
# add directories not set by users
@@ -287,11 +280,7 @@ class Context:
# Move old artifact cas to cas if it exists and create symlink
old_casdir = os.path.join(self.cachedir, "artifacts", "cas")
- if (
- os.path.exists(old_casdir)
- and not os.path.islink(old_casdir)
- and not os.path.exists(self.casdir)
- ):
+ if os.path.exists(old_casdir) and not os.path.islink(old_casdir) and not os.path.exists(self.casdir):
os.rename(old_casdir, self.casdir)
os.symlink(self.casdir, old_casdir)
@@ -316,9 +305,7 @@ class Context:
self.config_cache_quota_string = cache.get_str("quota")
try:
- self.config_cache_quota = utils._parse_size(
- self.config_cache_quota_string, cas_volume
- )
+ self.config_cache_quota = utils._parse_size(self.config_cache_quota_string, cas_volume)
except utils.UtilError as e:
raise LoadError(
"{}\nPlease specify the value in bytes or as a % of full disk space.\n"
@@ -335,9 +322,7 @@ class Context:
# Load remote execution config getting pull-artifact-files from it
remote_execution = defaults.get_mapping("remote-execution", default=None)
if remote_execution:
- self.pull_artifact_files = remote_execution.get_bool(
- "pull-artifact-files", default=True
- )
+ self.pull_artifact_files = remote_execution.get_bool("pull-artifact-files", default=True)
# This stops it being used in the remote service set up
remote_execution.safe_del("pull-artifact-files")
# Don't pass the remote execution settings if that was the only option
@@ -357,15 +342,7 @@ class Context:
# Load logging config
logging = defaults.get_mapping("logging")
logging.validate_keys(
- [
- "key-length",
- "verbose",
- "error-lines",
- "message-lines",
- "debug",
- "element-format",
- "message-format",
- ]
+ ["key-length", "verbose", "error-lines", "message-lines", "debug", "element-format", "message-format",]
)
self.log_key_length = logging.get_int("key-length")
self.log_debug = logging.get_bool("debug")
@@ -377,9 +354,7 @@ class Context:
# Load scheduler config
scheduler = defaults.get_mapping("scheduler")
- scheduler.validate_keys(
- ["on-error", "fetchers", "builders", "pushers", "network-retries"]
- )
+ scheduler.validate_keys(["on-error", "fetchers", "builders", "pushers", "network-retries"])
self.sched_error_action = scheduler.get_enum("on-error", _SchedulerErrorAction)
self.sched_fetchers = scheduler.get_int("fetchers")
self.sched_builders = scheduler.get_int("builders")
@@ -395,9 +370,7 @@ class Context:
if self.build_dependencies not in ["plan", "all"]:
provenance = build.get_scalar("dependencies").get_provenance()
raise LoadError(
- "{}: Invalid value for 'dependencies'. Choose 'plan' or 'all'.".format(
- provenance
- ),
+ "{}: Invalid value for 'dependencies'. Choose 'plan' or 'all'.".format(provenance),
LoadErrorReason.INVALID_DATA,
)
@@ -408,14 +381,7 @@ class Context:
# on the overrides are expected to validate elsewhere.
for overrides in self._project_overrides.values():
overrides.validate_keys(
- [
- "artifacts",
- "source-caches",
- "options",
- "strict",
- "default-mirror",
- "remote-execution",
- ]
+ ["artifacts", "source-caches", "options", "strict", "default-mirror", "remote-execution",]
)
@property
@@ -567,10 +533,7 @@ class Context:
log_level = CASLogLevel.WARNING
self._cascache = CASCache(
- self.cachedir,
- casd=self.use_casd,
- cache_quota=self.config_cache_quota,
- log_level=log_level,
+ self.cachedir, casd=self.use_casd, cache_quota=self.config_cache_quota, log_level=log_level,
)
return self._cascache