def metadata_to_db(pkg, package_name, success, runtime_id): # Setup packagegroup outside of package transaction if pkg.get('organization') and pkg['organization'].get('name'): packagegroup_name = pkg['organization']['name'] packagegroup = setup_package_group(packagegroup_name) if packagegroup is not None: packagegroup_id = packagegroup.id else: packagegroup_id = None else: packagegroup_name = None packagegroup_id = None with db.session.begin(): package = models.Package.query.filter_by( package_name=package_name).first() package.man_auto = 'auto' package.source_url = pkg['resources'][0]['url'] package.hash = pkg['resources'][0]['hash'] packages_groups = {pkg['name']: packagegroup_name} copy_package_attributes(package, pkg) package.package_group = packagegroup_id copy_package_fields(package, pkg) db.session.add(package) add_hardcoded_result(hardcoded_test.URL_EXISTS, runtime_id, package.id, success)
def unguarded_check_file(test_functions, codelists, file_name, runtime_id, package_id): xml_parsed, data = parse_xml(file_name) print file_name dqprocessing.add_hardcoded_result(hardcoded_test.VALID_XML, runtime_id, package_id, xml_parsed) if not xml_parsed: print "XML parse failed" return False check_data(runtime_id, package_id, test_functions, codelists, data) return True
def metadata_to_db(pkg, package_name, success, runtime_id): with db.session.begin(): package = models.Package.query.filter_by( package_name=package_name).first() package.man_auto = 'auto' package.source_url = pkg['resources'][0]['url'] copy_package_attributes(package, pkg) setup_package_group(package, pkg) copy_package_fields(package, pkg) db.session.add(package) add_hardcoded_result(hardcoded_test.URL_EXISTS, runtime_id, package.id, success)
def unguarded_check_file(test_functions, codelists, file_name, runtime_id, package_id): print "Filename to test: %s (%d)" % (file_name, package_id) if rm_results: delete_results(package_id) xml_parsed, data = parse_xml(file_name) dqprocessing.add_hardcoded_result(hardcoded_test.VALID_XML, runtime_id, package_id, xml_parsed) if not xml_parsed: print "XML parse failed" return False check_data(runtime_id, package_id, test_functions, codelists, data) return True