| 953 | | if output is None: |
|---|
| 954 | | self.raise_exception("Error: Could not find distribution for " + self.name) |
|---|
| 955 | | |
|---|
| 956 | | # Defaults. |
|---|
| 957 | | self.download_url = "" |
|---|
| 958 | | self.distance_from_pypi = 0 |
|---|
| 959 | | self.found_on_cheeseshop = False |
|---|
| 960 | | |
|---|
| 961 | | for line in captured_stdout.split('\n'): |
|---|
| 962 | | s = re.search(r"Reading http(.*)", line) |
|---|
| 963 | | if s: |
|---|
| 964 | | inspected_url = s.group(1) |
|---|
| 965 | | if not re.search(r"www.python.org\/pypi", inspected_url): |
|---|
| 966 | | self.distance_from_pypi += 1 |
|---|
| 967 | | continue |
|---|
| 968 | | s = re.search(r"Downloading (.*)", line) |
|---|
| 969 | | if s: |
|---|
| 970 | | self.download_url = s.group(1) |
|---|
| 971 | | break |
|---|
| 972 | | |
|---|
| 973 | | self.sandbox_pkg_file = output |
|---|
| 974 | | self.package = self.get_package_from_path(output) |
|---|
| 975 | | self.log.info("Downloaded package %s from %s" % (self.package, self.download_url)) |
|---|
| 976 | | |
|---|
| 977 | | if re.search(r"cheeseshop.python.org", self.download_url): |
|---|
| 978 | | self.found_on_cheeseshop = True |
|---|
| 979 | | |
|---|
| 980 | | except ImportError, e: |
|---|
| 981 | | msg = "Error: setuptools is not installed and is required for downloading a package by name\n" |
|---|
| 982 | | msg += "You can donwload and process a package by its full URL via the -u or --url option\n" |
|---|
| 983 | | msg += "Example: python cheesecake.py --url=http://www.mems-exchange.org/software/durus/Durus-3.1.tar.gz" |
|---|
| | 961 | except DistutilsError, e: |
|---|
| | 962 | # Bring back old stdout. |
|---|
| | 963 | captured_stdout = sys.stdout.read_buffer() |
|---|
| | 964 | sys.stdout = old_stdout |
|---|
| | 965 | log.set_threshold(old_threshold) |
|---|
| | 966 | |
|---|
| | 967 | # Drop all setuptools output as INFO. |
|---|
| | 968 | self.log.info("*** Begin setuptools output") |
|---|
| | 969 | map(self.log.info, captured_stdout.splitlines()) |
|---|
| | 970 | self.log.info(str(e)) |
|---|
| | 971 | self.log.info("*** End setuptools output") |
|---|
| | 972 | |
|---|
| | 973 | msg = "Error: setuptools returned an error: %s\n" % e |
|---|
| | 975 | |
|---|
| | 976 | if output is None: |
|---|
| | 977 | self.raise_exception("Error: Could not find distribution for " + self.name) |
|---|
| | 978 | |
|---|
| | 979 | # Defaults. |
|---|
| | 980 | self.download_url = "" |
|---|
| | 981 | self.distance_from_pypi = 0 |
|---|
| | 982 | self.found_on_cheeseshop = False |
|---|
| | 983 | |
|---|
| | 984 | for line in captured_stdout.split('\n'): |
|---|
| | 985 | s = re.search(r"Reading http(.*)", line) |
|---|
| | 986 | if s: |
|---|
| | 987 | inspected_url = s.group(1) |
|---|
| | 988 | if not re.search(r"www.python.org\/pypi", inspected_url): |
|---|
| | 989 | self.distance_from_pypi += 1 |
|---|
| | 990 | continue |
|---|
| | 991 | s = re.search(r"Downloading (.*)", line) |
|---|
| | 992 | if s: |
|---|
| | 993 | self.download_url = s.group(1) |
|---|
| | 994 | break |
|---|
| | 995 | |
|---|
| | 996 | self.sandbox_pkg_file = output |
|---|
| | 997 | self.package = self.get_package_from_path(output) |
|---|
| | 998 | self.log.info("Downloaded package %s from %s" % (self.package, self.download_url)) |
|---|
| | 999 | |
|---|
| | 1000 | if re.search(r"cheeseshop.python.org", self.download_url): |
|---|
| | 1001 | self.found_on_cheeseshop = True |
|---|