Пример #1
0
def actually_save_file(package_name, orig_url, pkg, runtime_id):
    # `pkg` is a CKAN dataset
    success = False
    directory = app.config['DATA_STORAGE_DIR']

    print "Attempting to fetch package", package_name, "from", orig_url
    url = fixURL(orig_url)
    path = os.path.join(directory, package_name + '.xml')

    success = manage_download(path, url)

    with report_error("  Wrote metadata to DB", 
                      "  Couldn't write metadata to DB"):
        metadata_to_db(pkg, package_name, success, runtime_id)

    with report_error("  Package tested",
                      "  Couldn't test package %s" % package_name):
        dqruntests.start_testing(package_name)
def actually_save_manual_file(package_name):
    success = False
    directory = app.config['DATA_STORAGE_DIR']

    package = models.Package.query.filter_by(
        package_name=package_name).first()

    url = fixURL(package.source_url)
    path = os.path.join(directory, package_name + '.xml')

    success = manage_download(path, url)

    with db.session.begin():
        package.hash = 'retrieved'
        db.session.add(package)

    with report_error("  Package tested",
                      "  Couldn't test package %s" % package_name):
        dqruntests.start_testing(package_name)