How to get symlink target in Python?

The problem with os.readlink() is it will only resolve 1 step of the link. We can have a situation where A links to another link B, and B link is dangling. $ ln -s /tmp/example/notexist /tmp/example/B $ ln -s /tmp/example/B /tmp/example/A $ ls -l /tmp/example A -> /tmp/example/B B -> /tmp/example/notexist Now in Python, os.readlink … Read more

Enable native NTFS symbolic links for Cygwin

⸻⸻  Short answer  ⸻⸻ Define environment variable: CYGWIN=winsymlinks:nativestrict As pointed out by mwm you may also have to go to the settings or to run bash as Administrator. See the Notes section. ⸻⸻  Long answer  ⸻⸻ Default Cygwin symlinks are just regular files By default Cygwin creates text files as workaround for Windows symlink flaw. … Read more

`os.symlink` vs `ln -s`

os.symlink creates a single symlink. ln -s creates multiple symlinks (if its last argument is a directory, and there’s more than one source). The Python equivalent is something like: dst = args[-1] for src in args[:-1]: os.symlink(src, os.path.join(dst, os.path.dirname(src))) So, how does it work when you do ln -s /home/guest/dir1/* /home/guest/dir2/? Your shell makes that … Read more

How do I overcome the “The symbolic link cannot be followed because its type is disabled.” error when getting the target of a symbolic link?

Well I found the answer, though to describe it as badly documented is an understatement! First of all, this TechEd article highlights the fact that users can “enable or disable any of the four evaluations that are available in symbolic links”. Those four “evaluations” include remote to local and local to remote. It doesn’t give … Read more

What happens when I clone a repository with symlinks on Windows?

Since version 1.5.3 of the native Git client git clone and git init will probe the target file system for symlink support and set the local repository configuration for core.symlinks accordingly, i.e. to false for FAT or NTFS. This makes symlinks created and committed e.g. under Linux appear as plain text files that contain the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)