diff options
Diffstat (limited to 'baserockimport/exts/python.to_lorry')
-rwxr-xr-x | baserockimport/exts/python.to_lorry | 73 |
1 files changed, 3 insertions, 70 deletions
diff --git a/baserockimport/exts/python.to_lorry b/baserockimport/exts/python.to_lorry index ebde27a..30f38e7 100755 --- a/baserockimport/exts/python.to_lorry +++ b/baserockimport/exts/python.to_lorry @@ -37,58 +37,6 @@ from importer_python_common import * from utils import warn, error import utils - -def find_repo_type(url): - - debug_vcss = False - - # Don't bother with detection if we can't get a 200 OK - logging.debug("Getting '%s' ..." % url) - - status_code = requests.get(url).status_code - if status_code != 200: - logging.debug('Got %d status code from %s, aborting repo detection' - % (status_code, url)) - return None - - logging.debug('200 OK for %s' % url) - logging.debug('Finding repo type for %s' % url) - - vcss = [('git', 'clone'), ('hg', 'clone'), - ('svn', 'checkout'), ('bzr', 'branch')] - - for (vcs, vcs_command) in vcss: - logging.debug('Trying %s %s' % (vcs, vcs_command)) - tempdir = tempfile.mkdtemp() - - p = subprocess.Popen([vcs, vcs_command, url], stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, stdin=subprocess.PIPE, - cwd=tempdir) - - # We close stdin on parent side to prevent the child from blocking - # if it reads on stdin - p.stdin.close() - - while True: - line = p.stdout.readline() - if line == '': - break - - if debug_vcss: - logging.debug(line.rstrip('\n')) - - p.wait() # even with eof on both streams, we still wait - - shutil.rmtree(tempdir) - - if p.returncode == 0: - logging.debug('%s is a %s repo' % (url, vcs)) - return vcs - - logging.debug("%s doesn't seem to be a repo" % url) - - return None - def filter_urls(urls): allowed_extensions = ['tar.gz', 'tgz', 'tar.Z', 'tar.bz2', 'tbz2', 'tar.lzma', 'tar.xz', 'tlz', 'txz', 'tar'] @@ -101,7 +49,7 @@ def filter_urls(urls): def get_releases(client, package_name): try: - releases = client.package_releases(package_name) + releases = client.package_releases(package_name, True) except Exception as e: error("Couldn't fetch release data:", e) @@ -185,23 +133,8 @@ class PythonLorryExtension(ImportExtension): logging.debug('Treating %s as %s' % (package_name, new_proj_name)) package_name = new_proj_name - try: - metadata = self.fetch_package_metadata(package_name) - except Exception as e: - error("Couldn't fetch package metadata: ", e) - - info = metadata.json()['info'] - - repo_type = (find_repo_type(info['home_page']) - if 'home_page' in info else None) - - if repo_type: - # TODO: Don't hardcode extname here. - print(utils.str_repo_lorry('python', lorry_prefix, package_name, - repo_type, info['home_page'])) - else: - print(generate_tarball_lorry(lorry_prefix, client, - package_name, version)) + print(generate_tarball_lorry(lorry_prefix, client, + package_name, version)) if __name__ == '__main__': PythonLorryExtension().run() |