message: Fix/harden move script
diff: """
  - file: llnl_lc_move_unused_tpl_dirs_to_graveyard.py
  + file: move_unused_tpl_dirs_to_graveyard.py
  description:
  - Reads JSON result from llnl_lc_find_unused_tpl_dirs.py,
  + Reads JSON result from find_unused_tpl_dirs.py,
  and moves those TPL dirs marked "unused" to the
  "_graveyard" for cleanup.
  @@ -23,34 +23,40 @@ import json
  from os.path import join as pjoin
  -from llnl_lc_build_tools import sexe
  +from llnl_lc_build_tools import *
  +gy_base = pjoin(get_shared_libs_dir(), "_graveyard")
  def graveyard_path(d):
  - # TODO harden +s test on RZ
  - return pjoin(d[:d.rfind("builds/")+7],"_graveyard")
  + path = d.replace(get_shared_libs_dir(), gy_base)
  + return path
  def main():
  + # Create directory structure if it's not there
  + for sys_type in get_supported_sys_types():
  + directory = pjoin(gy_base, sys_type)
  + if not os.path.exists(directory):
  + os.makedirs(directory)
  +
  summary_file ="tpl_dirs_summary.json"
  + if not os.path.exists(summary_file):
  + print("Error: Summary file from find_unused_tpl_dirs.py did not exist: {0}", summary_file)
  + return False
  +
  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)
  if __name__ == "__main__":
  - main()
  -
  -
  -
  -
  -
  -
  -
  -
  -
  + if main():
  + sys.exit(0)
  + sys.exit(1)
  