From 227690fca43d08f1c6cc9d19afc1013fe8f3eec0 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Fri, 8 Apr 2011 16:31:38 -0500 Subject: repo-validate: Verify genshi bundle list Signed-off-by: Sol Jerome --- src/sbin/bcfg2-repo-validate | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/sbin/bcfg2-repo-validate b/src/sbin/bcfg2-repo-validate index 554e4f72b..a5ba24898 100755 --- a/src/sbin/bcfg2-repo-validate +++ b/src/sbin/bcfg2-repo-validate @@ -151,27 +151,26 @@ if __name__ == '__main__': else: pset.add(ptuple) - filesets = {'metadata': (metadata_list, "%s/metadata.xsd"), - 'clients': (clients_list, "%s/clients.xsd"), - 'info': (info_list, "%s/info.xsd"), - 'bundle': (bundle_list, "%s/bundle.xsd"), - 'pkglist': (pkg_list, "%s/pkglist.xsd"), - 'base': (base_list, "%s/base.xsd"), - 'rules': (rules_list, "%s/rules.xsd"), - 'imageinfo': (imageinfo_list, "%s/report-configuration.xsd"), - 'services': (services_list, "%s/services.xsd"), - 'deps': (deps_list, "%s/deps.xsd"), - 'decisions': (dec_list, "%s/decisions.xsd"), - 'packages': (pkgcfg_list, "%s/packages.xsd"), - 'grouppatterns': (gp_list, "%s/grouppatterns.xsd"), - } + filesets = {"%s/metadata.xsd": metadata_list, + "%s/clients.xsd": clients_list, + "%s/info.xsd": info_list, + "%s/bundle.xsd": bundle_list + genshibundle_list, + "%s/pkglist.xsd": pkg_list, + "%s/base.xsd": base_list, + "%s/rules.xsd": rules_list, + "%s/report-configuration.xsd": imageinfo_list, + "%s/services.xsd": services_list, + "%s/deps.xsd": deps_list, + "%s/decisions.xsd": dec_list, + "%s/packages.xsd": pkgcfg_list, + "%s/grouppatterns.xsd": gp_list} failures = 0 - for k, (filelist, schemaname) in list(filesets.items()): + for schemaname, filelist in list(filesets.items()): try: - schema = lxml.etree.XMLSchema(lxml.etree.parse(open(schemaname%(schemadir)))) + schema = lxml.etree.XMLSchema(lxml.etree.parse(open(schemaname % (schemadir)))) except: - print("Failed to process schema %s" % (schemaname%(schemadir))) + print("Failed to process schema %s" % (schemaname % (schemadir))) failures = 1 continue for filename in filelist: @@ -223,5 +222,4 @@ if __name__ == '__main__': print(" Filename is %s" % fname) print(" Bundle name found in %s is %s" % (fname, bname)) - - raise SystemExit, failures + raise SystemExit(failures) -- cgit v1.2.3-1-g7c22 From 246557f31b1be5d73419434e2f05f7a7653de592 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Sat, 9 Apr 2011 14:27:56 -0500 Subject: Reports: PY3K compatibility fix for PEP 3114 Quoted from PEP 3114: The iterator protocol in Python 2.x consists of two methods: __iter__() called on an iterable object to yield an iterator, and next() called on an iterator object to yield the next item in the sequence. Using a for loop to iterate over an iterable object implicitly calls both of these methods. This PEP proposes that the next method be renamed to __next__, consistent with all the other protocols in Python in which a method is implicitly called as part of a language-level protocol, and that a built-in function named next be introduced to invoke __next__ method, consistent with the manner in which other protocols are explicitly invoked. Signed-off-by: Sol Jerome --- src/lib/Server/Reports/utils.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Reports/utils.py b/src/lib/Server/Reports/utils.py index 6010f366b..04fdbf985 100755 --- a/src/lib/Server/Reports/utils.py +++ b/src/lib/Server/Reports/utils.py @@ -1,10 +1,25 @@ """Helper functions for reports""" from django.conf.urls.defaults import * import re +import sys """List of filters provided by filteredUrls""" filter_list = ('server', 'state') +def increment(self): + """Return the next object from our array and fetch from the + database when needed""" + if self.block_count + self.count - self.step == self.max: + raise StopIteration + if self.block_count == 0 or self.count == self.step: + # Without list() this turns into LIMIT 1 OFFSET x queries + self.data = list(self.obj.all()[self.block_count: \ + (self.block_count + self.step)]) + self.block_count += self.step + self.count = 0 + self.count += 1 + return self.data[self.count - 1] + class BatchFetch(object): """Fetch Django objects in smaller batches to save memory""" @@ -20,19 +35,12 @@ class BatchFetch(object): def __iter__(self): return self - def __next__(self): - """Return the next object from our array and fetch from the - database when needed""" - if self.block_count + self.count - self.step == self.max: - raise StopIteration - if self.block_count == 0 or self.count == self.step: - # Without list() this turns into LIMIT 1 OFFSET x queries - self.data = list(self.obj.all()[self.block_count: \ - (self.block_count + self.step)]) - self.block_count += self.step - self.count = 0 - self.count += 1 - return self.data[self.count - 1] + if sys.hexversion > 0x03000000: + def __next__(self): + return increment(self) + else: + def next(self): + return increment(self) def generateUrls(fn): -- cgit v1.2.3-1-g7c22