SF.net SVN: gar:[23084] csw/mgar/gar/v2/lib

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Feb 28 10:48:53 CET 2014


Revision: 23084
          http://sourceforge.net/p/gar/code/23084
Author:   wahwah
Date:     2014-02-28 09:48:52 +0000 (Fri, 28 Feb 2014)
Log Message:
-----------
pkgdb: A number of fixes for the new APIs

These are the changes made on the web host to make catalog generation work.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/pkgdb.py
    csw/mgar/gar/v2/lib/python/rest.py
    csw/mgar/gar/v2/lib/web/pkgdb_web.py
    csw/mgar/gar/v2/lib/web/releases_web.py

Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py	2014-02-28 09:48:44 UTC (rev 23083)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py	2014-02-28 09:48:52 UTC (rev 23084)
@@ -205,9 +205,12 @@
   def __init__(self, debug=False):
     self.debug = debug
     config = configuration.GetConfig()
+    username, password = rest.GetUsernameAndPassword()
     self.rest_client = rest.RestClient(
         pkgdb_url=config.get('rest', 'pkgdb'),
         releases_url=config.get('rest', 'releases'),
+        username=username,
+        password=password,
         debug=debug)
 
   def SyncFromCatalogFile(self, osrel, arch, catrel, catalog_file,

Modified: csw/mgar/gar/v2/lib/python/rest.py
===================================================================
--- csw/mgar/gar/v2/lib/python/rest.py	2014-02-28 09:48:44 UTC (rev 23083)
+++ csw/mgar/gar/v2/lib/python/rest.py	2014-02-28 09:48:52 UTC (rev 23084)
@@ -22,8 +22,8 @@
 from lib.python import shell
 
 
-DEFAULT_TRIES = 1
-DEFAULT_RETRY_DELAY = 1
+DEFAULT_TRIES = 5
+DEFAULT_RETRY_DELAY = 10
 
 
 class ArgumentError(errors.Error):

Modified: csw/mgar/gar/v2/lib/web/pkgdb_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/pkgdb_web.py	2014-02-28 09:48:44 UTC (rev 23083)
+++ csw/mgar/gar/v2/lib/web/pkgdb_web.py	2014-02-28 09:48:52 UTC (rev 23084)
@@ -4,7 +4,7 @@
 
 import sys
 import os
-sys.path.append(os.path.join(os.path.split(__file__)[0], "..", ".."))
+# sys.path.append(os.path.join(os.path.split(__file__)[0], "..", ".."))
 
 import cjson
 import datetime
@@ -18,6 +18,9 @@
 
 from sqlobject import sqlbuilder
 
+# sys.stderr.write("Running Python binary from {}.\n".format(sys.executable))
+# sys.stderr.write("Python path is {}.\n".format(sys.path))
+
 from lib.python import checkpkg_lib
 from lib.python import models
 from lib.python import representations
@@ -499,16 +502,11 @@
 
   def GET(self, md5_sum):
     try:
-      pkg = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
+      blob = models.Srv4FileStatsBlob.selectBy(md5_sum=md5_sum).getOne()
     except sqlobject.main.SQLObjectNotFound, e:
       raise web.notfound()
     web.header('Content-type', 'application/x-vnd.opencsw.pkg;type=pkg-stats')
-    if pkg.data_obj_mimetype == 'application/json':
-      # If data are in JSON already, we can send them without decoding.
-      return pkg.data_obj.pickle
-    else:
-      data_structure = pkg.GetStatsStruct()
-      return cjson.encode(data_structure)
+    return blob.json
 
 
 class Srv4ByCatAndCatalogname(object):
@@ -753,5 +751,5 @@
 else:
   application = app_wrapper(app).wsgifunc()
   # application = app.wsgifunc()
-  from paste.exceptions.errormiddleware import ErrorMiddleware
-  application = ErrorMiddleware(application, debug=debugme)
+  # from paste.exceptions.errormiddleware import ErrorMiddleware
+  # application = ErrorMiddleware(application, debug=debugme)

Modified: csw/mgar/gar/v2/lib/web/releases_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/releases_web.py	2014-02-28 09:48:44 UTC (rev 23083)
+++ csw/mgar/gar/v2/lib/web/releases_web.py	2014-02-28 09:48:52 UTC (rev 23084)
@@ -5,7 +5,6 @@
 
 import sys
 import os
-sys.path.append(os.path.join(os.path.split(__file__)[0], "..", ".."))
 
 import base64
 import cjson

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