Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhudson committed Jan 31, 2023
1 parent 045ec74 commit 2dd0179
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion livefs_edit/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,27 @@ def install_debs(ctxt, debs: List[str] = ()):
run(['umount', rootfs_path])
os.unlink(rootfs_path)


def rm_ro(func, path, _):
"""Clear readonly attribute and retry removal"""
os.chmod(path, stat.S_IWRITE)
func(path)


def rm_f(path):
if os.path.exists(path):
if os.path.isdir(path):
shutil.rmtree(path, onerror = rm_ro)
shutil.rmtree(path, onerror=rm_ro)
else:
os.chmod(path, stat.S_IWRITE)
os.unlink(path)


@register_action()
def rm(ctxt, path):
rm_f(ctxt.p(path, allow_abs=True))


def download_snap(ctxt, snap_name, channel):
dldir = ctxt.tmpdir()
run([
Expand Down

0 comments on commit 2dd0179

Please sign in to comment.