[csw-devel] SF.net SVN: gar:[19971] csw/mgar/gar/v2/lib/python/catalog_gc.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Thu Dec 27 18:48:16 CET 2012


Revision: 19971
          http://gar.svn.sourceforge.net/gar/?rev=19971&view=rev
Author:   wahwah
Date:     2012-12-27 17:48:16 +0000 (Thu, 27 Dec 2012)
Log Message:
-----------
catalog-gc: Bugfix and update usage info

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/catalog_gc.py

Modified: csw/mgar/gar/v2/lib/python/catalog_gc.py
===================================================================
--- csw/mgar/gar/v2/lib/python/catalog_gc.py	2012-12-27 17:47:30 UTC (rev 19970)
+++ csw/mgar/gar/v2/lib/python/catalog_gc.py	2012-12-27 17:48:16 UTC (rev 19971)
@@ -1,16 +1,25 @@
 #!/opt/csw/bin/python2.6
 
-"""Garbage-collecting for a catalog.
+"""Garbage-collecting for the catalog tree.
 
 The allpkgs directory may contain unused files.  They should be deleted.
 """
 
+import logging
 import optparse
-import logging
 import os.path
+import pipes
 import re
 import common_constants
 
+USAGE = """%prog --catalog-tree /home/mirror/opencsw-official > gc_01.sh
+less gc_01.sh
+
+# Looks good?
+
+bash gc_01.sh
+"""
+
 class Error(Exception):
   """Base error."""
 
@@ -20,7 +29,7 @@
 
 class CatalogGarbageCollector(object):
 
-  ADDITIONAL_CATALOGS = ("legacy")
+  ADDITIONAL_CATALOGS = ("legacy",)
 
   def __init__(self, d):
     logging.debug("CatalogGarbageCollector(%s)", repr(d))
@@ -53,21 +62,21 @@
               l = catalogs_by_files.setdefault(p, [])
               l.append((catrel, arch, osrel_short))
     for p in allpkgs.difference(files_in_catalogs):
-      logging.debug("File %s is not used by any catalogs.", p)
-      print "rm %s/%s" % (allpkgs_path, p)
+      print "rm", pipes.quote(os.path.join(allpkgs_path, p))
 
 
 def main():
   parser = optparse.OptionParser()
-  parser.add_option("-c", "--catalog",
-      dest="catalog",
-      help="Catalog path")
+  parser.add_option("--catalog-tree",
+      dest="catalog_tree",
+      help=("Path to the catalog tree, that is the directory "
+            "containing subdirectories unstable, testing, etc."))
   options, args = parser.parse_args()
   logging.basicConfig(level=logging.DEBUG)
-  if not options.catalog:
+  if not options.catalog_tree:
     parser.print_usage()
-    raise UsageError("Missing catalog option, see --help.")
-  gcg = CatalogGarbageCollector(options.catalog)
+    raise UsageError("Missing the catalog tree option, see --help.")
+  gcg = CatalogGarbageCollector(options.catalog_tree)
   gcg.GarbageCollect()
 
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list