[ckan-changes] commit/ckanext-qa: 3 new changesets

Bitbucket commits-noreply at bitbucket.org
Wed Jul 27 17:07:25 UTC 2011


3 new changesets in ckanext-qa:

http://bitbucket.org/okfn/ckanext-qa/changeset/94ec73118521/
changeset:   94ec73118521
user:        John Glover
date:        2011-07-27 18:44:08
summary:     Ignore logging failures for now, DGU cannot write to stdout
affected #:  1 file (56 bytes)

--- a/ckanext/qa/lib/log.py	Wed Jul 27 13:26:36 2011 +0100
+++ b/ckanext/qa/lib/log.py	Wed Jul 27 17:44:08 2011 +0100
@@ -24,8 +24,10 @@
             norm = unicodedata.normalize('NFKD', unicode(message))
             # log as ascii
             logger.info(norm.encode('ascii', 'replace'))
-        except Exception as e:
-            print "Logging error:", e.message
+        except Exception:
+            # ignore for now
+            # TODO: tidy this up
+            pass
 
     def error(self, message):
         try:
@@ -33,7 +35,9 @@
             norm = unicodedata.normalize('NFKD', unicode(message))
             # log as ascii
             logger.error(norm.encode('ascii', 'replace'))
-        except Exception as e:
-            print "Logging error:", e.message
+        except Exception:
+            # ignore for now
+            # TODO: tidy this up
+            pass
 
 log = Logger()


http://bitbucket.org/okfn/ckanext-qa/changeset/72b266a99f0b/
changeset:   72b266a99f0b
user:        John Glover
date:        2011-07-27 18:50:08
summary:     [archive|qa] small changes to parameters to logic layer functions as a result of changes to the default branch
affected #:  5 files (203 bytes)

--- a/ckanext/qa/commands/archive.py	Wed Jul 27 17:44:08 2011 +0100
+++ b/ckanext/qa/commands/archive.py	Wed Jul 27 17:50:08 2011 +0100
@@ -105,10 +105,11 @@
         db_file = os.path.join(self.archive_folder, 'archive.db')
         # logic layer context dict
         context = {'model': model, 'session': model.Session,  'user': MAINTENANCE_AUTHOR}
+        data = {}
 
         if package_id:
-            context['id'] = package_id
-            package = get.package_show(context)
+            data['id'] = package_id
+            package = get.package_show(context, data)
             if package:
                 packages = [package]
             else:
@@ -129,9 +130,9 @@
             #     packages = [Session.query(Package).filter(Package.id == id[0]).first() for id in ids]
             # else:
             if limit:
-                context['limit'] = limit
+                data['limit'] = limit
                 log.info("Limiting results to %d packages" % limit)
-            packages = get.current_package_list_with_resources(context)
+            packages = get.current_package_list_with_resources(context, data)
 
         log.info("Total packages to update: %d" % len(packages))
         if not packages:


--- a/ckanext/qa/commands/qa.py	Wed Jul 27 17:44:08 2011 +0100
+++ b/ckanext/qa/commands/qa.py	Wed Jul 27 17:50:08 2011 +0100
@@ -109,10 +109,11 @@
             return
         results_file = os.path.join(self.archive_folder, 'archive.db')
         context = {'model': model, 'session': model.Session,  'user': MAINTENANCE_AUTHOR}
+        data = {}
 
         if package_id:
-            context['id'] = package_id
-            package = get.package_show(context)
+            data['id'] = package_id
+            package = get.package_show(context, data)
             if package:
                 packages = [package]
             else:
@@ -133,9 +134,9 @@
             #     packages = [Session.query(Package).filter(Package.id == id[0]).first() for id in ids]
             # else:
             if limit:
-                context['limit'] = limit
+                data['limit'] = limit
                 log.info("Limiting results to %d packages" % limit)
-            packages = get.current_package_list_with_resources(context)
+            packages = get.current_package_list_with_resources(context, data)
 
         log.info("Total packages to update: %d" % len(packages))
         if not packages:


--- a/ckanext/qa/controllers/qa_api.py	Wed Jul 27 17:44:08 2011 +0100
+++ b/ckanext/qa/controllers/qa_api.py	Wed Jul 27 17:50:08 2011 +0100
@@ -152,8 +152,9 @@
             {'resource_available': 'true|false', 'resource_hash': '<value>',
              'resource_cache': '<value>'}
         """
-        context = {'model': model, 'id': id, 'user': c.user or c.author}
-        pkg = get.package_show(context)
+        context = {'model': model, 'user': c.user or c.author}
+        data_dict = {'id': id}
+        pkg = get.package_show(context, data_dict)
 
         if not pkg:
             abort(404, _('Package not found'))


--- a/ckanext/qa/lib/archive.py	Wed Jul 27 17:44:08 2011 +0100
+++ b/ckanext/qa/lib/archive.py	Wed Jul 27 17:50:08 2011 +0100
@@ -52,6 +52,8 @@
         archive_result(db_file, resource['id'], "Invalid url scheme")
     # check that query string is valid
     # see: http://trac.ckan.org/ticket/318
+    # TODO: check urls with a better validator? 
+    #       eg: ll.url (http://www.livinglogic.de/Python/url/Howto.html)?
     elif any(['/' in parsed_url.query, ':' in parsed_url.query]):
         archive_result(db_file, resource['id'], "Invalid URL")
     else:
@@ -157,5 +159,5 @@
         'id': resource['id'], 'model': model, 'session': model.Session, 
         'user': MAINTENANCE_AUTHOR
     }
-    update.resource_update(resource, context)
+    update.resource_update(context, resource)
     return length, resource['hash']


--- a/ckanext/qa/lib/package_scorer.py	Wed Jul 27 17:44:08 2011 +0100
+++ b/ckanext/qa/lib/package_scorer.py	Wed Jul 27 17:50:08 2011 +0100
@@ -97,7 +97,7 @@
         resource[u'openness_score'] = openness_score
         resource[u'openness_score_reason'] = reason
         resource[u'openness_score_failure_count'] = unicode(openness_score_failure_count)
-        update.resource_update(resource, context)
+        update.resource_update(context, resource)
         log.info('Score for resource: %s (%s)' % (openness_score, reason))
 
     # package openness score
@@ -127,6 +127,6 @@
         'user': MAINTENANCE_AUTHOR, 'extras_as_string': True
     }
     package['extras'] = package_extras
-    update.package_update(package, context)
+    update.package_update(context, package)
     log.info('Finished QA analysis of package: %s (score = %s)' 
         % (package['name'], package_openness_score))


http://bitbucket.org/okfn/ckanext-qa/changeset/649b45bdf540/
changeset:   649b45bdf540
user:        John Glover
date:        2011-07-27 19:05:01
summary:     [qa_extension] Bug fix: don't look for archive file if no resource hash set
affected #:  1 file (163 bytes)

--- a/ckanext/qa/controllers/qa_api.py	Wed Jul 27 17:50:08 2011 +0100
+++ b/ckanext/qa/controllers/qa_api.py	Wed Jul 27 18:05:01 2011 +0100
@@ -167,7 +167,8 @@
         resources = []
         for resource in pkg.get('resources', []):
             r = {}
-            r['resource_hash'] = resource[u'hash']
+            hash = resource.get('hash', '')
+            r['resource_hash'] = hash
             r['resource_available'] = 'unknown'
             r['resource_cache'] = ''
             # look at archive results to see if resource was found
@@ -176,17 +177,19 @@
                 if archive_result['success'] == u'True':
                     r['resource_available'] = 'true'
                 else:
-                    r['resource_available'] = 'false'
-                    # see if we have a saved copy
-                    cache = os.path.join(archive_folder, pkg[u'name'])
-                    # TODO: update this to handle other formats
-                    #       save extension info in archive file
-                    cache = os.path.join(cache, resource[u'hash'] + '.csv')
-                    if os.path.exists(cache):
-                        # create the url to serve this copy
-                        webstore = config.get('ckan.webstore_url', 'http://test-webstore.ckan.net')
-                        r['resource_cache'] = webstore + '/downloads/' + \
-                            pkg[u'name'] + '/' + resource[u'hash'] + '.csv'
+                    # if no hash value set then we don't have an archive file either
+                    if hash:
+                        r['resource_available'] = 'false'
+                        # see if we have a saved copy
+                        cache = os.path.join(archive_folder, pkg[u'name'])
+                        # TODO: update this to handle other formats
+                        #       save extension info in archive file
+                        cache = os.path.join(cache, hash + '.csv')
+                        if os.path.exists(cache):
+                            # create the url to serve this copy
+                            webstore = config.get('ckan.webstore_url', 'http://test-webstore.ckan.net')
+                            r['resource_cache'] = webstore + '/downloads/' + \
+                                pkg[u'name'] + '/' + hash + '.csv'
             # add to resource list
             resources.append(r)
         return {'resources': resources}

Repository URL: https://bitbucket.org/okfn/ckanext-qa/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list