[csw-devel] SF.net SVN: gar:[13476] csw/mgar/gar/v2/lib/python/pkgdb.py
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sun Feb 27 01:35:54 CET 2011
Revision: 13476
http://gar.svn.sourceforge.net/gar/?rev=13476&view=rev
Author: wahwah
Date: 2011-02-27 00:35:54 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
pkgdb: Control catalogs imported/generated
Put some safety measure in place, to avoid generation and importing of wrong
catalogs.
Signed-off-by: Maciej Blizinski <maciej at opencsw.org>
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/pkgdb.py
Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py 2011-02-27 00:35:21 UTC (rev 13475)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py 2011-02-27 00:35:54 UTC (rev 13476)
@@ -74,6 +74,14 @@
"""
DEFAULT_TEMPLATE_FILENAME = "../lib/python/pkg-review-template.html"
+CATALOGS_ALLOWED_TO_GENERATE = frozenset([
+ "unstable",
+ "dublin",
+ "kiel",
+])
+CATALOGS_ALLOWED_TO_BE_IMPORTED = frozenset([
+ "current",
+])
class Error(Exception):
@@ -191,6 +199,9 @@
Imports srv4 files if necessary.
"""
+ if catrel not in CATALOGS_ALLOWED_TO_BE_IMPORTED:
+ raise UsageError("Catalogs that can be imported: %s"
+ % CATALOGS_ALLOWED_TO_BE_IMPORTED)
catalog_dir = os.path.dirname(catalog_file)
# The plan:
# - read in the catalog file, and build a md5-filename correspondence
@@ -536,9 +547,14 @@
for obj in res:
print obj.catalogname, obj.basename, obj.md5_sum
elif command == 'gen-cat':
- catrel = 'unstable'
+ catrel = options.catrel or 'dublin'
if options.catrel and options.catrel != catrel:
logging.warn("Generating the %s catalog.", catrel)
+ if catrel not in CATALOGS_ALLOWED_TO_GENERATE:
+ raise UsageError(
+ "Catalog %s not allowed to be generated from the database. "
+ "Allowed catalogs are: %s"
+ % (catrel, CATALOGS_ALLOWED_TO_GENERATE))
if len(args) != 2:
raise UsageError("Wrong number of arguments, see usage.")
allpkgs_dir, target_dir = args
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