Created
October 13, 2015 15:48
-
-
Save tychoish/b48fb6ad6f7589097787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_symlink(name, target): | |
if not os.path.islink(name): | |
m = "created link pointing to {0} named {1}".format(target, name) | |
try: | |
os.symlink(target, name) | |
logger.info(m + " (py)") | |
except AttributeError: | |
from win32file import CreateSymbolicLink | |
CreateSymbolicLink(name, target) | |
logger.info(m + " (win)") | |
except ImportError: | |
logger.error("platform does not contain support for symlinks.") | |
logger.info("Windows users need pywin32.") | |
else: | |
logger.info('link pointing to {0} named {1} already exists'.foramt(target, name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment