Skip to content

Symlinks

Niklas edited this page Oct 28, 2022 · 2 revisions

Symlinks

It's possible that you want to set a symlink to your BackupTool installation when you don't want to walk into the specific folder.

ln -s /path/to/BackupTool.py BackupTool

To make this possible we have to detect that the Program is called via Symlink. For this we can use the pathlib function is_symlink(). pathlib.Path(__file__).is_symlink() it returns us a True when the Code is accessed via Symlink and False when not. Then we can read the link and resolve the path to the Parent directory. pathlib.Path(os.readlink(__file__)).parent.resolve() will return the absolute path of the programs root.

Source

Clone this wiki locally