1
0
Fork 0
mirror of synced 2024-06-30 12:41:09 -04:00

improve linking error message (admin rights most likely)

This commit is contained in:
Matt Richards 2021-04-26 14:48:44 +10:00
parent 153661d255
commit 725bf739a9

View file

@ -4,6 +4,7 @@ import shutil
import dotbot import dotbot
import dotbot.util import dotbot.util
import subprocess import subprocess
import textwrap
class Link(dotbot.Plugin): class Link(dotbot.Plugin):
@ -286,8 +287,7 @@ class Link(dotbot.Plugin):
print("Link found:", symlink_dest_at_target_path, "expected", dotfile_source) print("Link found:", symlink_dest_at_target_path, "expected", dotfile_source)
else: else:
# Symlink is broken or dangling # Symlink is broken or dangling
self._log.warning("Symlink Invalid %s -> %s" % (target_path_to_link_at, self._log.warning("Symlink Invalid %s -> %s" % (target_path_to_link_at, symlink_dest_at_target_path))
symlink_dest_at_target_path))
return success_flag return success_flag
if target_path_exists: # file/ folder we want to put symlink in already exists if target_path_exists: # file/ folder we want to put symlink in already exists
@ -305,8 +305,11 @@ class Link(dotbot.Plugin):
try: try:
print(f"running symlink with args '{dotfile_source}', '{destination}'") print(f"running symlink with args '{dotfile_source}', '{destination}'")
os.symlink(dotfile_source, destination) os.symlink(dotfile_source, destination)
except OSError: except OSError as e:
self._log.warning("Linking failed %s -> %s" % (target_path_to_link_at, dotfile_source)) msg = textwrap.fill(
f"Linking failed {target_path_to_link_at} -> {dotfile_source}\n ({e})", width=80, subsequent_indent=" ")
self._log.warning(msg)
except Exception as e: except Exception as e:
print( print(
f"SYMLINK FAILED with arguments os.symlink({dotfile_source}, {destination})", f"SYMLINK FAILED with arguments os.symlink({dotfile_source}, {destination})",