[csw-devel] SF.net SVN: gar:[13223] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon Feb 7 09:20:42 CET 2011
Revision: 13223
http://gar.svn.sourceforge.net/gar/?rev=13223&view=rev
Author: wahwah
Date: 2011-02-07 08:20:41 +0000 (Mon, 07 Feb 2011)
Log Message:
-----------
pkgdb: Add --force-unpack
This option makes srv4 files to be unpacked and reindexed.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/package.py
csw/mgar/gar/v2/lib/python/package_stats.py
csw/mgar/gar/v2/lib/python/pkgdb.py
Modified: csw/mgar/gar/v2/lib/python/package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package.py 2011-02-07 04:43:03 UTC (rev 13222)
+++ csw/mgar/gar/v2/lib/python/package.py 2011-02-07 08:20:41 UTC (rev 13223)
@@ -48,6 +48,7 @@
def __init__(self, pkg_path, debug=False):
super(CswSrv4File, self).__init__()
+ logging.debug("CswSrv4File(%s, debug=%s)", repr(pkg_path), debug)
self.pkg_path = pkg_path
self.workdir = None
self.gunzipped_path = None
@@ -81,6 +82,7 @@
# Causing the class to stat the .gz file. This call throws away the
# result, but the result will be cached as a object member.
self.GetMtime()
+ self.GetMd5sum()
base_name_gz = os.path.split(self.pkg_path)[1]
shutil.copy(self.pkg_path, self.GetWorkDir())
self.pkg_path = os.path.join(self.GetWorkDir(), base_name_gz)
Modified: csw/mgar/gar/v2/lib/python/package_stats.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats.py 2011-02-07 04:43:03 UTC (rev 13222)
+++ csw/mgar/gar/v2/lib/python/package_stats.py 2011-02-07 08:20:41 UTC (rev 13223)
@@ -462,7 +462,7 @@
self.logger = logging
self.debug = debug
- def CollectStatsFromFiles(self, file_list, catalog_file):
+ def CollectStatsFromFiles(self, file_list, catalog_file, force_unpack=False):
args_display = file_list
if len(args_display) > 5:
args_display = args_display[:5] + ["...more..."]
@@ -488,7 +488,7 @@
# removes the temporary directory from the disk. This allows to process
# the whole catalog.
stats = stats_list.pop()
- stats.CollectStats()
+ stats.CollectStats(force=force_unpack)
data_list.append(stats.GetAllStats())
pbar.update(counter.next())
pbar.finish()
Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py 2011-02-07 04:43:03 UTC (rev 13222)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py 2011-02-07 08:20:41 UTC (rev 13223)
@@ -185,7 +185,8 @@
def __init__(self, debug=False):
self.debug = debug
- def SyncFromCatalogFile(self, osrel, arch, catrel, catalog_file):
+ def SyncFromCatalogFile(self, osrel, arch, catrel, catalog_file,
+ force_unpack=False):
"""Syncs a given catalog from a catalog file.
Imports srv4 files if necessary.
@@ -223,7 +224,8 @@
collector = package_stats.StatsCollector(
logger=logging,
debug=self.debug)
- new_statdicts = collector.CollectStatsFromFiles(file_list, None)
+ new_statdicts = collector.CollectStatsFromFiles(
+ file_list, None, force_unpack=force_unpack)
new_statdicts_by_md5 = {}
if new_statdicts:
logging.info("Marking imported packages as registered.")
@@ -299,9 +301,9 @@
db_catalog.AddSrv4ToCatalog(
sqo_srv4, osrel, arch, catrel)
- def SyncFromCatalogTree(self, catrel, base_dir):
- logging.debug("SyncFromCatalogTree(%s, %s)",
- repr(catrel), repr(base_dir))
+ def SyncFromCatalogTree(self, catrel, base_dir, force_unpack=False):
+ logging.debug("SyncFromCatalogTree(%s, %s, force_unpack=%s)",
+ repr(catrel), repr(base_dir), force_unpack)
if not os.path.isdir(base_dir):
raise UsageError("%s is not a diractory" % repr(base_dir))
if catrel not in common_constants.DEFAULT_CATALOG_RELEASES:
@@ -320,7 +322,8 @@
logging.warning("Could not find %s, skipping.", repr(catalog_file))
continue
logging.info(" %s", catalog_file)
- self.SyncFromCatalogFile(osrel, arch, catrel, catalog_file)
+ self.SyncFromCatalogFile(osrel, arch, catrel, catalog_file,
+ force_unpack=force_unpack)
def ComposeCatalogFilePath(self, base_dir, osrel, arch):
short_osrel = osrel.replace("SunOS", "")
@@ -356,6 +359,9 @@
parser.add_option("--profile", dest="profile",
default=False, action="store_true",
help="Turn on profiling")
+ parser.add_option("--force-unpack", dest="force_unpack",
+ default=False, action="store_true",
+ help="Force unpacking of packages")
options, args = parser.parse_args()
if options.debug:
logging.basicConfig(level=logging.DEBUG)
@@ -414,7 +420,8 @@
logger=logging,
debug=options.debug)
file_list = args
- stats_list = collector.CollectStatsFromFiles(file_list, None)
+ stats_list = collector.CollectStatsFromFiles(file_list, None,
+ force_unpack=options.force_unpack)
for stats in stats_list:
logging.debug(
"Importing %s, %s",
@@ -512,7 +519,7 @@
raise UsageError("Wrong number of arguments, see usage.")
ci = CatalogImporter(debug=options.debug)
catrel, base_dir = args
- ci.SyncFromCatalogTree(catrel, base_dir)
+ ci.SyncFromCatalogTree(catrel, base_dir, options.force_unpack)
elif (command, subcommand) == ('show', 'cat'):
sqo_osrel, sqo_arch, sqo_catrel = GetSqoTriad(
options.osrel, options.arch, options.catrel)
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