def main(): summary_file = "tpl_dirs_summary.json" r = json.load(open(summary_file)) print "" print "[# of referenced %d ]" % len(r["referenced"]) print "[# of found %d ]" % len(r["found"]) print "[# of active %d ]" % len(r["active"]) print "[# of unused %d ]" % len(r["unused"]) for d in r["unused"]: cmd = "mv %s %s" % (d, graveyard_path(d)) sexe(cmd)
def find_tpl_dirs_in_host_configs_for_all_branches(): """ Returns a list of tpl dirs referenced in host configs in all of axom's git branches. """ res = [] for branch in list_git_branches(): print "\n[checking host configs in branch %s]" % branch sexe("git checkout %s" % branch,echo=True) for tpl_dir in find_tpl_dirs_in_host_configs(): res.append(tpl_dir) return unique(res)
def list_git_branches(): """ Returns a list of all remote git branches """ branches = [] rcode, branches_out = sexe("git branch -a", ret_output=True) for l in branches_out.split(): if l.startswith("remotes/origin"): branch_name = l[l.find("remotes/origin"):] branches.append(branch_name) return branches
def clone_axom(): """ Creates a fresh clone of axom """ cwd = os.getcwd() tmp_dir = os.path.abspath("_tmp_clone_%s" % (get_timestamp())) if os.path.isdir(tmp_dir): shutil.rmdir(tmp_dir) os.mkdir(tmp_dir) os.chdir(tmp_dir) print "[cloning axom into %s]" % pjoin(tmp_dir,"axom") res = sexe("git clone ssh://[email protected]:7999/atk/axom.git",echo=True) if res != 0: print "[ERROR: clone of axom repo failed]" sys.exit(res) os.chdir(cwd) return tmp_dir