exec/file: document symlink() and check return code
This commit is contained in:
parent
4154b2dfe3
commit
a9edbfd07d
1 changed files with 5 additions and 1 deletions
|
@ -161,10 +161,14 @@ def root_makedir(path, parents: bool = True):
|
|||
|
||||
|
||||
def symlink(source, target):
|
||||
"Create a symlink at `target`, pointing at `source`"
|
||||
try:
|
||||
os.symlink(source, target)
|
||||
except:
|
||||
run_root_cmd(['ln', '-s', source, target])
|
||||
result = run_root_cmd(['ln', '-s', source, target])
|
||||
assert isinstance(result, subprocess.CompletedProcess)
|
||||
if result.returncode:
|
||||
raise Exception(f'Symlink creation of {target} pointing at {source} failed')
|
||||
|
||||
|
||||
def get_temp_dir(register_cleanup=True, mode: int = 0o0755):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue