Skip to content

Commit

Permalink
util: standardize on term 'mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
dbungert committed Oct 3, 2023
1 parent 85af88e commit ddc3345
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions subiquity/models/subiquity.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def _cloud_init_files(self):
("etc/cloud/ds-identify.cfg", "policy: enabled\n", 0o644),
]
# Add cloud-init clean hooks to support golden-image creation.
cfg_files = ["/" + path for (path, _content, _cmode) in files]
cfg_files = ["/" + path for (path, _content, _mode) in files]
cfg_files.extend(self.network.rendered_config_paths())
if lsb_release()["release"] not in ("20.04", "22.04"):
cfg_files.append("/etc/cloud/cloud-init.disabled")
Expand Down Expand Up @@ -467,10 +467,10 @@ def configure_cloud_init(self):
if self.source.current.variant == "core":
# can probably be supported but requires changes
return
for path, content, cmode in self._cloud_init_files():
for path, content, mode in self._cloud_init_files():
path = os.path.join(self.target, path)
os.makedirs(os.path.dirname(path), exist_ok=True)
write_file(path, content, cmode=cmode)
write_file(path, content, mode=mode)

def _media_info(self):
if os.path.exists("/cdrom/.disk/info"):
Expand Down
8 changes: 4 additions & 4 deletions subiquitycore/file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def set_log_perms(target, *, isdir=True, group_write=False, mode=None):


@contextlib.contextmanager
def open_perms(filename, *, cmode=None):
if cmode is None:
cmode = _DEF_PERMS_FILE
def open_perms(filename, *, mode=None):
if mode is None:
mode = _DEF_PERMS_FILE

tf = None
try:
Expand All @@ -59,7 +59,7 @@ def open_perms(filename, *, cmode=None):
tf = tempfile.NamedTemporaryFile(dir=dirname, delete=False, mode="w")
yield tf
tf.close()
set_log_perms(tf.name, mode=cmode)
set_log_perms(tf.name, mode=mode)
os.rename(tf.name, filename)
except OSError as e:
if tf is not None:
Expand Down

0 comments on commit ddc3345

Please sign in to comment.