def scan_url(pkg, url, options): 'http://guides.rubygems.org/rubygems-org-api/#gemversion' gem = guess_gem(pkg.cpv, url) if not gem: output.eerror("Can't guess gem name using %s and %s" % \ (pkg.cpv, url)) return [] output.einfo("Using RubyGem API: %s" % gem) return scan_pkg(pkg, {'data': gem})
def scan_url(pkg, urls, options, on_progress=None): versions = [] if on_progress: progress_available = 70 num_urls = sum([len(urls[fn]) for fn in urls]) if num_urls > 0: progress_increment = progress_available / num_urls else: progress_increment = 0 for filename in urls: for url in urls[filename]: if on_progress and progress_available > 0: on_progress(increment=progress_increment) progress_available -= progress_increment output.einfo("SRC_URI is '%s'" % url) if '://' not in url: output.einfo("Invalid url '%s'" % url) continue try: url_handler = find_best_handler('url', pkg, url) if url_handler: for o in options: versions += url_handler.scan_url(pkg, url, o) else: output.eerror("Can't find a suitable handler!") except Exception as e: output.ewarn( "Handler failed: [%s] %s" % (e.__class__.__name__, e.message) ) if versions and CONFIG['oneshot']: break if on_progress and progress_available > 0: on_progress(increment=progress_available) return versions
def scan(cpv, url): 'http://guides.rubygems.org/rubygems-org-api/#gemversion' gem = guess_gem(cpv, url) if not gem: output.eerror("Can't guess gem name using %s and %s" % \ (cpv, url)) return [] url = 'http://rubygems.org/api/v1/versions/%s.json' % gem output.einfo("Using: " + url) try: fp = helpers.urlopen(url) except urllib2.URLError: return [] except IOError: return [] if not fp: return [] data = fp.read() versions = json.loads(data) if not versions: return [] cp, ver, rev = portage.pkgsplit(cpv) ret = [] for version in versions: up_pv = version['number'] pv = helpers.gentoo_mangle_version(up_pv) if helpers.version_filtered(cp, ver, pv): continue url = 'http://rubygems.org/gems/%s-%s.gem' % (gem, up_pv) ret.append((url, pv, HANDLER_NAME, CONFIDENCE)) return ret
def scan_pkg(pkg, options): package = options['data'] output.einfo("Using Gnome json cache: " + package) fp = urllib.request.urlopen('/'.join( [GNOME_URL_SOURCE, package, 'cache.json'])) content = fp.read() fp.close() cache = json.loads(content, encoding='ascii') if cache[0] != 4: output.eerror('Unknow cache format detected') return [] versions = cache[2][package] if not versions: return [] versions.reverse() cp, ver, _rev = portage.pkgsplit(pkg.cpv) ret = [] for up_pv in versions: pv = mangling.mangle_version(up_pv, options) if helpers.version_filtered(cp, ver, pv): continue up_files = cache[1][package][up_pv] for tarball_comp in ('tar.xz', 'tar.bz2', 'tar.gz'): if tarball_comp in up_files: url = '/'.join( [GNOME_URL_SOURCE, package, up_files[tarball_comp]]) break else: output.ewarn('No tarball for release %s' % up_pv) ret.append((url, pv, HANDLER_NAME, CONFIDENCE)) return ret
def scan_pkg(pkg, options): package = options['data'] output.einfo("Using Gnome json cache: " + package) fp = urllib2.urlopen('/'.join([GNOME_URL_SOURCE, package, 'cache.json'])) content = fp.read() fp.close() cache = json.loads(content, encoding='ascii') if cache[0] != 4: output.eerror('Unknow cache format detected') return [] versions = cache[2][package] if not versions: return [] versions.reverse() cp, ver, _rev = portage.pkgsplit(pkg.cpv) ret = [] for up_pv in versions: pv = mangling.mangle_version(up_pv, options) if helpers.version_filtered(cp, ver, pv): continue up_files = cache[1][package][up_pv] for tarball_comp in ('tar.xz', 'tar.bz2', 'tar.gz'): if tarball_comp in up_files: url = '/'.join([GNOME_URL_SOURCE, package, up_files[tarball_comp]]) break else: output.ewarn('No tarball for release %s' % up_pv) ret.append((url, pv, HANDLER_NAME, CONFIDENCE)) return ret