Commits

Rodrigo Bistolfi committed 11501ec

timezone: test for symlink

Comments (0)

Files changed (1)

vinstall/backend/timezone.py

     src = os.path.join(ZONEINFO, tz)
     dst = os.path.join(root, LOCAL_TZ)
     cpy = os.path.join(root, "etc/localtime-copied-from")
-    if os.path.exists(dst):
+    if _file_exists(dst):
         os.remove(dst)
-    if os.path.exists(cpy):
+    if _file_exists(cpy):
         os.remove(cpy)
-    print src, dst, cpy
     return os.symlink(src, dst)
 
 
     conf = os.path.join(root, "etc/hardwareclock")
     with open(conf, "w") as hwc:
         hwc.write("# /etc/hardwareclock - vinstall\n%s" % t)
+
+
+def _file_exists(f):
+    """Like os.path.exists but returns True for broken symlinks also"""
+    if os.path.exists(f) or os.path.islink(f):
+        return True
+    return False