def test_tarball(self): pkg = Package('configure') tarball = Tarball(pkg.tarball_filename) self.assertEqual(tarball, pkg.tarball) self.assertEqual(pkg, tarball.package) with CapturedOutput() as (stdout, stderr): with CapturedLog() as _: tarball.download() self.assertEqual(stdout.getvalue(), '') self.assertTrue(tarball.checksum_verifies())
def test_tarball(self): pkg = Package('configure') tarball = Tarball(pkg.tarball_filename) self.assertEqual(tarball, pkg.tarball) self.assertEqual(pkg, tarball.package) with CapturedOutput() as (stdout, stderr): with CapturedLog() as log: tarball.download() self.assertEqual(stdout.getvalue(), '') self.assertTrue(tarball.checksum_verifies())
def run(self): progress = True url = None print_fastest_mirror = None destination = None for arg in sys.argv[1:]: if arg.startswith('--print-fastest-mirror'): url = "" print_fastest_mirror = True continue if arg.startswith('--quiet'): progress = False continue if url is None: url = arg continue if destination is None: destination = arg continue raise ValueError('too many arguments') if url is None: print(dedent(self.__doc__.format(SAGE_DISTFILES=SAGE_DISTFILES))) sys.exit(2) try: if url.startswith('http://') or url.startswith('https://') or url.startswith('ftp://'): Download(url, destination, progress=progress, ignore_errors=True).run() elif print_fastest_mirror: url = "fastest mirror" # For error message print(MirrorList().fastest) else: # url is a tarball name tarball = Tarball(url) tarball.download() if destination is not None: tarball.save_as(destination) except BaseException: try: stars = '*' * 72 + '\n' sys.stderr.write(stars) try: import traceback traceback.print_exc(file=sys.stderr) sys.stderr.write(stars) except: pass sys.stderr.write("Error downloading %s\n"%(url,)) sys.stderr.write(stars) finally: sys.exit(1)
def run_name(self, tarball_filename): """ name: Find the package name given a tarball filename $ sage-package name pari-2.8-1564-gdeac36e.tar.gz pari """ tarball = Tarball(os.path.basename(tarball_filename)) print(tarball.package.name)
def name(self, tarball_filename): """ Find the package name given a tarball filename $ sage --package name pari-2.8-1564-gdeac36e.tar.gz pari """ log.debug('Looking up package name for %s', tarball_filename) tarball = Tarball(os.path.basename(tarball_filename)) print(tarball.package.name)
def run(self): progress = True url = None destination = None for arg in sys.argv[1:]: if arg.startswith('--print-fastest-mirror'): print(MirrorList().fastest) sys.exit(0) if arg.startswith('--quiet'): progress = False continue if url is None: url = arg continue if destination is None: destination = arg continue raise ValueError('too many arguments') if url is None: print(dedent(self.__doc__.format(SAGE_DISTFILES=SAGE_DISTFILES))) sys.exit(1) if url.startswith('http://') or url.startswith('https://') or url.startswith('ftp://'): Download(url, destination, progress=progress, ignore_errors=True).run() else: # url is a tarball name tarball = Tarball(url) tarball.download() if destination is not None: tarball.save_as(destination)
def download_tarball(self, tarball_filename, destination=None, allow_upstream=False): tarball = Tarball(tarball_filename) tarball.download(allow_upstream=allow_upstream) if destination is not None: tarball.save_as(destination)
def tarball(self): """ Return the (primary) tarball If there are multiple tarballs (currently unsupported), this property returns the one that is unpacked automatically. OUTPUT: Instance of :class:`sage_bootstrap.tarball.Tarball` """ if self.__tarball is None: from sage_bootstrap.tarball import Tarball self.__tarball = Tarball(self.tarball_filename, package=self) return self.__tarball
def run(self): progress = True url = None print_fastest_mirror = None destination = None for arg in sys.argv[1:]: if arg.startswith('--print-fastest-mirror'): url = "" print_fastest_mirror = True continue if arg.startswith('--quiet'): progress = False continue if url is None: url = arg continue if destination is None: destination = arg continue raise ValueError('too many arguments') if url is None: print(dedent(self.__doc__.format(SAGE_DISTFILES=SAGE_DISTFILES))) sys.exit(2) try: if url.startswith('http://') or url.startswith( 'https://') or url.startswith('ftp://'): Download(url, destination, progress=progress, ignore_errors=True).run() elif print_fastest_mirror: url = "fastest mirror" # For error message print(MirrorList().fastest) else: # url is a tarball name tarball = Tarball(url) tarball.download() if destination is not None: tarball.save_as(destination) except BaseException: try: stars = '*' * 72 + '\n' sys.stderr.write(stars) try: import traceback traceback.print_exc(file=sys.stderr) sys.stderr.write(stars) except: pass sys.stderr.write("Error downloading %s\n" % (url, )) sys.stderr.write(stars) finally: sys.exit(1)
def download_tarball(self, tarball_filename, destination=None): tarball = Tarball(tarball_filename) tarball.download() if destination is not None: tarball.save_as(destination)