def download_package(self, package): assert type(package) is RepoPackage sh.mkdirs(DOWNLOAD_CACHE) auth = licensing.get_be_license_auth() send_license = package.requires_be_license license_installed = auth is not None # A license is required for this package, but no license is installed if not license_installed and send_license: msg = '\n'.join([ wrapped('If you have purchased ActivePython Business Edition, ' 'please login to your account at:'), ' https://account.activestate.com/', wrapped('and download and run the license installer for your ' 'platform.'), '', wrapped('Please visit <%s> to learn more about the ' 'ActivePython Business Edition offering.' % \ licensing.BE_HOME_PAGE)]) raise error.PackageAccessError( package, 'requires Business Edition subscription', msg) try: # At this point, the user is already known to have a BE license file_location, _ = net.download_file( package.download_url, DOWNLOAD_CACHE, dict( auth=auth, use_cache=True, # XXX: this introduces network delay # (If-None-Match) despite having the file # in download cache # TODO: abstract client.store...autosync save_properties=True, start_info='{{status}}: [{0}] {1} {2}'.format( six.moves.urlparse(package.download_url).netloc, package.name, package.printable_version)), interactive=self.pypmenv.options['interactive']) except six.moves.HTTPError as e: reason = str(e) LOG.debug("HTTPError while accessing URL: %s -- reason: %s", package.download_url, reason) if send_license and e.code in (401, 402, 403): msg = wrapped( 'Your ActivePython Business Edition subscription seems to ' 'have expired. Please visit your account at ' 'https://account.activestate.com/ to renew your subscription.' ) else: msg = '' raise error.PackageAccessError(package, reason, msg) return file_location
def download_package(self, package): assert type(package) is RepoPackage sh.mkdirs(DOWNLOAD_CACHE) LOG.info('Get: [%s] %s %s', six.moves.urlparse(package.download_url).netloc, package.name, package.printable_version) auth = licensing.get_be_license_auth() send_license = package.requires_be_license license_installed = auth is not None # A license is required for this package, but no license is installed if not license_installed and send_license: msg = '\n'.join([ wrapped('If you have purchased ActivePython Business Edition, ' 'please login to your account at:'), ' https://account.activestate.com/', wrapped('and download and run the license installer for your ' 'platform.'), '', wrapped('Please visit <%s> to learn more about the ' 'ActivePython Business Edition offering.' % \ licensing.BE_HOME_PAGE)]) raise error.PackageAccessError( package, 'requires Business Edition subscription', msg) try: # At this point, the user is already known to have a BE license file_location = net.download_file( package.download_url, DOWNLOAD_CACHE, dict(auth=auth), interactive=self.pypmenv.options['interactive']) except six.moves.HTTPError as e: reason = str(e) LOG.debug("HTTPError while accessing URL: %s -- reason: %s", package.download_url, reason) if send_license and e.code in (401, 402, 403): msg = wrapped( 'Your ActivePython Business Edition subscription seems to ' 'have expired. Please visit your account at ' 'https://account.activestate.com/ to renew your subscription.' ) else: msg = '' raise error.PackageAccessError(package, reason, msg) return file_location