mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-17 12:44:38 +03:00
@@ -14,6 +14,8 @@ Current changes
|
||||
Added
|
||||
-----
|
||||
|
||||
* Option to specify mirror site.
|
||||
|
||||
Changed
|
||||
-------
|
||||
|
||||
|
||||
@@ -33,43 +33,42 @@ class QtPackage:
|
||||
url = ""
|
||||
archive = ""
|
||||
desc = ""
|
||||
mirror = None
|
||||
|
||||
def __init__(self, name, archive_url, archive, package_desc):
|
||||
def __init__(self, name, archive_url, archive, package_desc, has_mirror=False):
|
||||
self.name = name
|
||||
self.url = archive_url
|
||||
self.archive = archive
|
||||
self.desc = package_desc
|
||||
|
||||
def get_name(self):
|
||||
return self.name
|
||||
|
||||
def get_url(self):
|
||||
return self.url
|
||||
|
||||
def get_archive(self):
|
||||
return self.archive
|
||||
|
||||
def get_desc(self):
|
||||
return self.desc
|
||||
self.has_mirror = has_mirror
|
||||
|
||||
|
||||
class QtArchives:
|
||||
BASE_URL = 'https://download.qt.io/online/qtsdkrepository/'
|
||||
archives = []
|
||||
base = None
|
||||
|
||||
def __init__(self, os_name, qt_version, target, arch):
|
||||
def __init__(self, os_name, qt_version, target, arch, mirror=None):
|
||||
self.qt_version = qt_version
|
||||
self.target = target
|
||||
self.arch = arch
|
||||
self.base = mirror
|
||||
if mirror is not None:
|
||||
self.has_mirror = True
|
||||
else:
|
||||
self.base = self.BASE_URL
|
||||
qt_ver_num = qt_version.replace(".", "")
|
||||
if os_name == 'windows':
|
||||
archive_url = self.BASE_URL + os_name + '_x86/' + target + '/' + 'qt5_' + qt_ver_num + '/'
|
||||
archive_url = self.base + os_name + '_x86/' + target + '/' + 'qt5_' + qt_ver_num + '/'
|
||||
else:
|
||||
archive_url = self.BASE_URL + os_name + '_x64/' + target + '/' + 'qt5_' + qt_ver_num + '/'
|
||||
archive_url = self.base + os_name + '_x64/' + target + '/' + 'qt5_' + qt_ver_num + '/'
|
||||
|
||||
# Get packages index
|
||||
update_xml_url = "{0}Updates.xml".format(archive_url)
|
||||
try:
|
||||
if mirror is not None:
|
||||
r = requests.get(update_xml_url)
|
||||
else:
|
||||
r = aqt.metalink.get(update_xml_url)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
print("Caught download error: %s" % e.args)
|
||||
@@ -98,7 +97,8 @@ class QtArchives:
|
||||
package_desc = packageupdate.find("Description").text
|
||||
for archive in downloadable_archives:
|
||||
package_url = archive_url + name + "/" + full_version + archive
|
||||
self.archives.append(QtPackage(name, package_url, archive, package_desc))
|
||||
self.archives.append(QtPackage(name, package_url, archive, package_desc,
|
||||
has_mirror=(mirror is not None)))
|
||||
|
||||
if len(self.archives) == 0:
|
||||
print("Error while parsing package information!")
|
||||
|
||||
12
aqt/cli.py
12
aqt/cli.py
@@ -36,6 +36,7 @@ class Cli():
|
||||
target = args.target
|
||||
os_name = args.host
|
||||
output_dir = args.outputdir
|
||||
mirror = args.mirror
|
||||
if arch is None:
|
||||
if os_name == "linux" and target == "desktop":
|
||||
arch = "gcc_64"
|
||||
@@ -48,11 +49,15 @@ class Cli():
|
||||
args.print_help()
|
||||
exit(1)
|
||||
qt_version = args.qt_version
|
||||
if mirror is not None:
|
||||
if not mirror.startswith('http://') or mirror.startswith('https://') or mirror.startswith('ftp://'):
|
||||
args.print_help()
|
||||
exit(1)
|
||||
|
||||
if output_dir is not None:
|
||||
QtInstaller(QtArchives(os_name, qt_version, target, arch)).install(target_dir=output_dir)
|
||||
QtInstaller(QtArchives(os_name, qt_version, target, arch, mirror=mirror)).install(target_dir=output_dir)
|
||||
else:
|
||||
QtInstaller(QtArchives(os_name, qt_version, target, arch)).install()
|
||||
QtInstaller(QtArchives(os_name, qt_version, target, arch, mirror=mirror)).install()
|
||||
|
||||
sys.stdout.write("\033[K")
|
||||
print("Finished installation")
|
||||
@@ -83,6 +88,9 @@ class Cli():
|
||||
"\nandroid: android_x86, android_armv7")
|
||||
install_parser.add_argument('-O', '--outputdir', nargs='?',
|
||||
help='Target output directory(default current directory)')
|
||||
install_parser.add_argument('-m', '--mirror', nargs='?',
|
||||
help="Specify mirror base url such as http://mirrors.ocf.berkeley.edu/qt/, "
|
||||
"where 'online' folder exist.")
|
||||
list_parser = subparsers.add_parser('list')
|
||||
list_parser.set_defaults(func=self.run_list)
|
||||
list_parser.add_argument("qt_version", help="Qt version in the format of \"5.X.Y\"")
|
||||
|
||||
@@ -50,11 +50,14 @@ class QtInstaller:
|
||||
|
||||
@staticmethod
|
||||
def retrieve_archive(package, path=None):
|
||||
archive = package.get_archive()
|
||||
url = package.get_url()
|
||||
archive = package.archive
|
||||
url = package.url
|
||||
print("-Downloading {}...".format(url))
|
||||
try:
|
||||
if package.has_mirror:
|
||||
r = aqt.metalink.get(url, stream=True)
|
||||
else:
|
||||
r = requests.get(url, stream=True)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
print("Caught download error: %s" % e.args)
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user