SF.net SVN: gar:[23336] csw/mgar/gar/v2
guengel at users.sourceforge.net
guengel at users.sourceforge.net
Sat Apr 5 23:33:29 CEST 2014
Revision: 23336
http://sourceforge.net/p/gar/code/23336
Author: guengel
Date: 2014-04-05 21:33:27 +0000 (Sat, 05 Apr 2014)
Log Message:
-----------
Changed lib/python/chkdbcat.py so that it uses gen-catalog-index.
Modified Paths:
--------------
csw/mgar/gar/v2/bin/chkdbcat
csw/mgar/gar/v2/lib/python/chkdbcat.py
csw/mgar/gar/v2/lib/python/chkdbcat_test.py
Modified: csw/mgar/gar/v2/bin/chkdbcat
===================================================================
--- csw/mgar/gar/v2/bin/chkdbcat 2014-04-05 20:05:52 UTC (rev 23335)
+++ csw/mgar/gar/v2/bin/chkdbcat 2014-04-05 21:33:27 UTC (rev 23336)
@@ -7,8 +7,8 @@
class MyCheckDBCatalog(chkdbcat.CheckDBCatalog):
"""Class overriding CheckDBCatalog.notify()"""
- def __init__(self, catrel, arch, osrel, fn_ts, chkcat, verbose=False):
- super(MyCheckDBCatalog,self).__init__(catrel, arch, osrel, fn_ts, chkcat)
+ def __init__(self, catrel, arch, osrel, fn_ts, gencat_bin, chkcat, verbose=False):
+ super(MyCheckDBCatalog,self).__init__(catrel, arch, osrel, fn_ts, gencat_bin, chkcat)
self.__verbose = verbose
def notify(self, date, addr, pkginfo):
@@ -26,6 +26,8 @@
parser.add_argument('--os-release', required=True)
parser.add_argument('--timestamp-file', default='/var/cache/chkdbcat/timestamp.json')
parser.add_argument('--chkcat-path', default='/opt/csw/bin/chkcat')
+ parser.add_argument('--gen-catalog-path',
+ help="Path to gen-catalog-index")
return parser.parse_args()
def main():
@@ -37,6 +39,7 @@
if args.verbose: print("Checking Database Catalog {0} {2} {1}".format(args.catalog_release, args.arch, args.os_release))
with MyCheckDBCatalog(args.catalog_release, args.arch,
args.os_release, args.timestamp_file,
+ args.gen_catalog_path,
args.chkcat_path, args.verbose) as checker:
success = checker.check()
if args.verbose:
Modified: csw/mgar/gar/v2/lib/python/chkdbcat.py
===================================================================
--- csw/mgar/gar/v2/lib/python/chkdbcat.py 2014-04-05 20:05:52 UTC (rev 23335)
+++ csw/mgar/gar/v2/lib/python/chkdbcat.py 2014-04-05 21:33:27 UTC (rev 23336)
@@ -11,6 +11,7 @@
import datetime
import dateutil.parser
import logging
+import os
import os.path
import shutil
import subprocess
@@ -20,7 +21,6 @@
from lib.python import configuration
from lib.python.shell import ShellCommand
from lib.python.rest import RestClient, GetUsernameAndPassword
-from lib.python.generate_catalog_file import CatalogFileGenerator
class FSLock(object):
"""Simple Lock class
@@ -43,6 +43,37 @@
os.rmdir(self.__dirname)
+class GenerateCatalog(object):
+ """Dumping a database catalog to disk in a format digestable for chkcat.
+
+ Replacement for lib.python.generate_catalog_file
+
+ """
+
+ def __init__(self, catrel,
+ arch,
+ osrel,
+ catgenbin):
+ self._catrel = catrel
+ self._arch = arch
+ self._osrel = osrel
+ self._catgenbin = catgenbin
+
+ def generate_catalog(self, catalogdir):
+ """Generate the catalog and place it to :param catalogdir:"""
+ logging.debug("Generate catalog %s %s %s using %s/catalog", self._catrel,
+ self._osrel,
+ self._arch,
+ self._catgenbin)
+
+ (retval,
+ wdc1,
+ wdc2) = ShellCommand([self._catgenbin,
+ "-arch", self._arch,
+ "-catalog-release", self._catrel,
+ "-os-release", self._osrel,
+ "-output", os.path.join(catalogdir, "catalog")])
+
class TimestampRecord(object):
"""Record Timestamp for a given Catalog, Architecture, and OS Release into a json encoded file."""
def __init__(self, fn):
@@ -268,13 +299,16 @@
removed by __exit__().
"""
- def __init__(self, catrel, arch, osrel, fn_ts, chkcat="/opt/csw/bin/chkcat",
+ def __init__(self, catrel, arch, osrel, fn_ts, gen_catalog_bin,
+ chkcat="/opt/csw/bin/chkcat",
cattiming_class=CatalogTiming,
tsrecord_class=TimestampRecord):
"""Constructor.
"fn_ts" is the path name to the time stamp file.
+ "gen_catalog_bin" is the path to the gen-catalog-index binary
+
"chkcat" is the path to `chkcat'. By default
`/opt/csw/bin/chkcat'.
@@ -291,8 +325,8 @@
username=username,
password=password)
- self.__catalogfgen = CatalogFileGenerator(
- catrel, arch, osrel, self.rest_client)
+ self.__catalogfgen = GenerateCatalog(catrel, arch, osrel,
+ gen_catalog_bin)
self.__chkcat = chkcat
# store for later use
@@ -348,7 +382,7 @@
def fetch_db_cat(self):
"""Fetch catalog stored in database into temporary direcotry."""
assert self.tmpdir is not None
- self.__catalogfgen.GenerateCatalog(self.tmpdir)
+ self.__catalogfgen.generate_catalog(self.tmpdir)
def run_chkcat(self):
"""Run `chkcat' on catalog retrieved into temporary directory."""
Modified: csw/mgar/gar/v2/lib/python/chkdbcat_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/chkdbcat_test.py 2014-04-05 20:05:52 UTC (rev 23335)
+++ csw/mgar/gar/v2/lib/python/chkdbcat_test.py 2014-04-05 21:33:27 UTC (rev 23336)
@@ -240,7 +240,7 @@
]
}
}
-
+
def notify(self, date, addr, pkginfo):
assert date == self.expected_notification_on[addr]['lastsuccessful']
@@ -253,20 +253,28 @@
for p in pkginfo:
assert p['fullname'] in self.expected_notification_on[addr]['newpkgs']
-
+
def setUp(self):
self.__timestamp_file = '/tmp/TestCheckDBCatalog.ts'
def test_InvalidCatalog(self):
"""Test a locally generated invalid catalog"""
-
- with self.TCheckDBCatalogInvalid('unstable','sparc','SunOS5.10', self.__timestamp_file, cattiming_class=TCatalogTiming) as test:
+
+ with self.TCheckDBCatalogInvalid('unstable', 'sparc',
+ 'SunOS5.10',
+ self.__timestamp_file,
+ 'go/bin/gen-catalog-index',
+ cattiming_class=TCatalogTiming) as test:
self.assertFalse(test.check())
def test_ValidCatalog(self):
"""Test a locally generated valid catalog"""
- with self.TCheckDBCatalogValid('unstable','sparc','SunOS5.10', self.__timestamp_file, cattiming_class=TCatalogTiming) as test:
+ with self.TCheckDBCatalogValid('unstable', 'sparc',
+ 'SunOS5.10',
+ self.__timestamp_file,
+ 'go/bin/gen-catalog-index',
+ cattiming_class=TCatalogTiming) as test:
self.assertFalse(test.check())
def test_Notification(self):
@@ -275,16 +283,20 @@
with TimestampRecord(self.__timestamp_file) as tsobj:
tsobj.set('unstable','sparc','SunOS5.10',datetime.datetime(2013,5,17,0,0,0))
- with self.TCheckDBCatalogNotification('unstable', 'sparc', 'SunOS5.10', self.__timestamp_file, cattiming_class=TCatalogTiming) as test:
+ with self.TCheckDBCatalogNotification('unstable', 'sparc',
+ 'SunOS5.10',
+ self.__timestamp_file,
+ 'go/bin/gen-catalog-index',
+ cattiming_class=TCatalogTiming) as test:
self.assertFalse(test.check())
def tearDown(self):
try:
os.unlink(self.__timestamp_file)
except:
- pass
-
+ pass
+
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
unittest.main()
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