Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
    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)
Пример #4
0
    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)
Пример #5
0
Файл: app.py Проект: yjjcc/sage
 def download_tarball(self, tarball_filename, destination=None):
     tarball = Tarball(tarball_filename)
     tarball.download()
     if destination is not None:
         tarball.save_as(destination)
Пример #6
0
Файл: app.py Проект: drupel/sage
 def download_tarball(self, tarball_filename, destination=None):
     tarball = Tarball(tarball_filename)
     tarball.download()
     if destination is not None:
         tarball.save_as(destination)