X-Git-Url: https://code.delx.au/mediapc-tools/blobdiff_plain/94d80ba0aef34044f6b96f82c73e3328ef4a7407..fe310300a648b827f7f2bbc35f4527acdb6d5a6a:/mythsymlink diff --git a/mythsymlink b/mythsymlink index a8391ac..42a4f9b 100755 --- a/mythsymlink +++ b/mythsymlink @@ -1,6 +1,7 @@ #!/usr/bin/env python2 import os +import random import re import socket import sys @@ -77,11 +78,17 @@ for row in cursor: if not os.path.isfile(source): continue + if os.path.isfile(dest): + dest = os.path.splitext(dest)[0] + ' - unique' + str(random.randint(1000, 9999)) + extn + dirnames = dest.split("/")[:-1] for i in xrange(1, len(dirnames)+1): dirname = "/".join(dirnames[:i]) if not os.path.isdir(dirname): os.mkdir(dirname) - os.symlink(source, dest) - + try: + os.symlink(source, dest) + except Exception, e: + print e, "--", source, "->", dest + sys.exit(1)