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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Tue Mar 4 09:59:43 CET 2014


Revision: 23129
          http://sourceforge.net/p/gar/code/23129
Author:   wahwah
Date:     2014-03-04 08:59:42 +0000 (Tue, 04 Mar 2014)
Log Message:
-----------
chkdbcat: Make it executable (tests too)

chkdbcat_test: Add the #! line

chkdbcat: Fix unit tests and adapt to new code

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

Property Changed:
----------------
    csw/mgar/gar/v2/lib/python/chkdbcat.py
    csw/mgar/gar/v2/lib/python/chkdbcat_test.py

Modified: csw/mgar/gar/v2/lib/python/chkdbcat.py
===================================================================
--- csw/mgar/gar/v2/lib/python/chkdbcat.py	2014-03-04 08:35:50 UTC (rev 23128)
+++ csw/mgar/gar/v2/lib/python/chkdbcat.py	2014-03-04 08:59:42 UTC (rev 23129)
@@ -1,3 +1,4 @@
+#!/opt/csw/bin/python2.6
 """Check catalog data stored in the database for consistency.
 
 Check catalog data stored in the database for consistency using Peter
@@ -5,7 +6,6 @@
 
 Notifications for invalid catalogs can be customized by overriding
 CheckDBCat.notify().
-
 """
 import cjson
 import datetime
@@ -16,8 +16,10 @@
 import subprocess
 import sys
 import tempfile
+
+from lib.python import configuration
 from lib.python.shell import ShellCommand
-from lib.python.rest import RestClient
+from lib.python.rest import RestClient, GetUsernameAndPassword
 from lib.python.generate_catalog_file import CatalogFileGenerator
 
 class FSLock(object):
@@ -221,13 +223,12 @@
             ]
 
             """
-            return [dict(self.__list_to_dict_genrator(v)) for v in jdat]
+            return [dict(self.__list_to_dict_generator(v)) for v in jdat]
 
       def fetch(self):
             """Fetch timing information using REST."""
-            return RestClient().GetCatalogTimingInformation(self.__catrel,
-                                                          self.__arch,
-                                                          self.__osrel)
+            return self.rest_client.GetCatalogTimingInformation(
+                self.__catrel, self.__arch, self.__osrel)
 
       def upload_newer_than(self, date):
             """Retrieve timing information on upload newer than "date"."""
@@ -282,7 +283,16 @@
             methods.
 
             """
-            self.__catalogfgen = CatalogFileGenerator(catrel, arch, osrel)
+            config = configuration.GetConfig()
+            username, password = GetUsernameAndPassword()
+            self.rest_client = RestClient(
+                pkgdb_url=config.get('rest', 'pkgdb'),
+                releases_url=config.get('rest', 'releases'),
+                username=username,
+                password=password)
+
+            self.__catalogfgen = CatalogFileGenerator(
+                catrel, arch, osrel, self.rest_client)
             self.__chkcat = chkcat
 
             # store for later use
@@ -321,7 +331,8 @@
             if pkginfo['uploadby'] is not None and pkginfo['uploadby'] != "web":
                   return pkginfo['uploadby']+'@opencsw.org'
             else:
-                  return RestClient().GetMaintainerByMd5(pkginfo['md5'])['maintainer_email']
+                  return self.rest_client.GetMaintainerByMd5(
+                      pkginfo['md5'])['maintainer_email']
 
       def notify(self, date, addr, pkginfo):
             """Notification.


Property changes on: csw/mgar/gar/v2/lib/python/chkdbcat.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: csw/mgar/gar/v2/lib/python/chkdbcat_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/chkdbcat_test.py	2014-03-04 08:35:50 UTC (rev 23128)
+++ csw/mgar/gar/v2/lib/python/chkdbcat_test.py	2014-03-04 08:59:42 UTC (rev 23129)
@@ -1,3 +1,5 @@
+#!/opt/csw/bin/python2.6
+
 """Tests for chkdbcat.py."""
 
 import os
@@ -284,5 +286,5 @@
       
 
 if __name__ == '__main__':
-      logging.basicConfig(level=logging.DEBUG)
+      logging.basicConfig(level=logging.INFO)
       unittest.main()


Property changes on: csw/mgar/gar/v2/lib/python/chkdbcat_test.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
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