def refresh_links(base, scripts): def link(filename, orig_dir): goodfile = join(orig_dir, filename) assert goodfile in allfiles for (dirpath, dirnames, filenames) in walkfiles: for f in filenames: if f == filename: sym = join(dirpath, f) sys.stderr.write("\tLinking %s (to %s)\n" % (path.shorten(sym), path.shorten(goodfile))) os.symlink(goodfile, sym) assert isdir(base) assert isdir(scripts) sys.stderr.write("\n\nRefreshing links below %s...\n" % base) path.set_base(base) import os # Retrieve all files below the base dir walkfiles = os.walk(base) allfiles = [] for (dirpath, dirnames, filenames) in walkfiles: # Remove all variables.pyc for f in filenames: if f == "variables.pyc": os.remove(join(dirpath, f)) else: allfiles.append(join(dirpath, f)) # Point all variables.py to the one in scripts/ link("variables.py", scripts) # Point all variables.pm to the one in scripts/ link("variables.pm", scripts)
while len(str) < 12: str = " " + str return str (options, args) = parser.parse_args() all = ["base", "scripts", "data"] dir = {} dir["base"] = options.base dir["scripts"] = options.scripts dir["data"] = options.data dir["home"] = "/home/turian" #thisdir = os.path.realpath(os.getcwd()) thisdir = wrap(os.getcwd()) path.set_base(thisdir) sys.stderr.write("%s directory:\t%s\n" % (align("current"), thisdir)) dir.keys().sort() for d in all: #dir[d] = os.path.realpath(dir[d]) dir[d] = wrap(dir[d]) sys.stderr.write("%s directory:\t%s\n" % (align(d), dir[d])) alldirs = [d for d in dir.values()] for d in alldirs: if not isdir(d): sys.stderr.write("FATAL: Directory does not exist:\n%s\n" % d) assert isdir(d) if commonprefix(alldirs + [thisdir]) != thisdir: