コード例 #1
0
ファイル: expected.py プロジェクト: thriqon/cargo-port
def main(galaxy_package_file, id, version=None):
    with open(galaxy_package_file, 'r') as handle:
        for ld in yield_packages(handle):
            if ld['id'].lower() != id.lower():
                continue

            if version is not None and ld['version'].lower() != version.lower():
                continue

            print """<action type="download_by_url" sha256sum="{0[sha]}">
    {1}
</action>""".format(ld, depot_url(ld))
コード例 #2
0
ファイル: gsl.py プロジェクト: thriqon/cargo-port
def get(package_id, download_location):
    package_found = False
    for ld in yield_packages(urllib2.urlopen(PACKAGE_SERVER + 'urls.tsv')):
        # TODO: check platform/architecture, failover to all if available?
        # iid, version, platform, architecture, upstream_url, checksum, alternate_url = line.split('\t')
        if ld['id'] == package_id.strip() and ld['platform']== 'src':
            package_found = True
            # I worry about this being unreliable. TODO: add target filename column?
            pkg_name = package_name(ld)
            storage_path = os.path.join(download_location, pkg_name)
            url = depot_url(ld)
            urllib.urlretrieve(url, storage_path)
            download_checksum = hashlib.sha256(open(storage_path, 'rb').read()).hexdigest()
            if ld['checksum'] != download_checksum:
                print ('Checksum does not match, something seems to be wrong.\n'
                       '{expected}\t(expected)\n{actual}\t(downloaded)').format(
                           expected=ld['checksum'],
                           actual=download_checksum)
            else:
                print 'Download successful for %s.' % (pkg_name)
    if not package_found:
        print 'Package (%s) could not be found in this server.' % (package_id)