[csw-devel] SF.net SVN: gar:[13077] csw/mgar/gar/v2/lib
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon Jan 24 01:07:20 CET 2011
Revision: 13077
http://gar.svn.sourceforge.net/gar/?rev=13077&view=rev
Author: wahwah
Date: 2011-01-24 00:07:20 +0000 (Mon, 24 Jan 2011)
Log Message:
-----------
csw-upload-pkg: Don't try to send UNCOMMITTED
Catch it early locally, but also have a guard on the server side.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
csw/mgar/gar/v2/lib/python/opencsw_test.py
csw/mgar/gar/v2/lib/web/releases_web.py
Modified: csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/csw_upload_pkg.py 2011-01-23 20:42:43 UTC (rev 13076)
+++ csw/mgar/gar/v2/lib/python/csw_upload_pkg.py 2011-01-24 00:07:20 UTC (rev 13077)
@@ -30,6 +30,10 @@
pass
+class PackageCheckError(Error):
+ """A problem with the package."""
+
+
class Srv4Uploader(object):
def __init__(self, filenames, debug=False):
@@ -39,6 +43,12 @@
def Upload(self):
for filename in self.filenames:
+ parsed_basename = opencsw.ParsePackageFileName(
+ os.path.basename(filename))
+ if parsed_basename["vendortag"] != "CSW":
+ raise PackageCheckError(
+ "Package vendor tag is %s instead of CSW."
+ % parsed_basename["vendortag"])
self._UploadFile(filename)
def _GetFileMd5sum(self, filename):
@@ -77,12 +87,13 @@
self._InsertIntoCatalog(filename, arch, osrel, file_metadata)
def _InsertIntoCatalog(self, filename, arch, osrel, file_metadata):
- logging.info("_InsertIntoCatalog(%s, %s, %s)", repr(arch), repr(osrel), repr(filename))
+ logging.info(
+ "_InsertIntoCatalog(%s, %s, %s)",
+ repr(arch), repr(osrel), repr(filename))
md5_sum = self._GetFileMd5sum(filename)
basename = os.path.basename(filename)
parsed_basename = opencsw.ParsePackageFileName(basename)
logging.debug("parsed_basename: %s", parsed_basename)
-
url = (
"%scatalogs/unstable/%s/%s/%s/"
% (BASE_URL, arch, osrel, md5_sum))
Modified: csw/mgar/gar/v2/lib/python/opencsw_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw_test.py 2011-01-23 20:42:43 UTC (rev 13076)
+++ csw/mgar/gar/v2/lib/python/opencsw_test.py 2011-01-24 00:07:20 UTC (rev 13077)
@@ -116,6 +116,7 @@
parsed = opencsw.ParsePackageFileName(file_name)
self.assertEqual(parsed["arch"], "sparc")
self.assertEqual(parsed["catalogname"], "boost-jam")
+ self.assertEqual(parsed["vendortag"], "UNCOMMITTED")
def testParsePackageFileName_Nonsense(self):
"""Checks if the function can sustain a non-conformant string."""
Modified: csw/mgar/gar/v2/lib/web/releases_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/releases_web.py 2011-01-23 20:42:43 UTC (rev 13076)
+++ csw/mgar/gar/v2/lib/web/releases_web.py 2011-01-24 00:07:20 UTC (rev 13077)
@@ -138,6 +138,11 @@
if arch_name == 'all':
raise checkpkg_lib.CatalogDatabaseError("Cannot add to 'all' catalog.")
srv4 = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
+ parsed_basename = opencsw.ParsePackageFileName(srv4.basename)
+ if parsed_basename["vendortag"] != "CSW":
+ raise checkpkg_lib.CatalogDatabaseError(
+ "Package vendor tag is %s instead of CSW."
+ % parsed_basename["vendortag"])
if not srv4.registered:
# Package needs to be registered for releases
stats = srv4.GetStatsStruct()
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