Fix issue when mirror site is https

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
Hiroshi Miura
2019-11-24 14:11:01 +09:00
parent e3e001fb99
commit 2375b3338f
2 changed files with 26 additions and 13 deletions

View File

@@ -93,15 +93,15 @@ class Cli():
exit(1) exit(1)
return arch return arch
def _check_mirror(self, args): def _check_mirror(self, mirror):
mirror = args.base if mirror is None:
if mirror is not None:
if not mirror.startswith('http://') or mirror.startswith('https://') or mirror.startswith('ftp://'):
args.print_help()
exit(1)
else:
new_url = altlink('https://download.qt.io/timestamp.txt', blacklist=self.settings.blacklist) new_url = altlink('https://download.qt.io/timestamp.txt', blacklist=self.settings.blacklist)
mirror = new_url[:-14] mirror = new_url[:-14]
elif mirror.startswith('http://') or mirror.startswith('https://') or mirror.startswith('ftp://'):
pass
else:
self.parser.print_help()
exit(1)
return mirror return mirror
def _check_modules_arg(self, qt_version, modules): def _check_modules_arg(self, qt_version, modules):
@@ -121,7 +121,7 @@ class Cli():
arch = self._set_arch(args, arch, os_name, target, qt_version) arch = self._set_arch(args, arch, os_name, target, qt_version)
modules = args.modules modules = args.modules
sevenzip = self._set_sevenzip(args) sevenzip = self._set_sevenzip(args)
mirror = self._check_mirror(args) mirror = self._check_mirror(args.base)
if not self._check_qt_arg_combination(qt_version, os_name, target, arch): if not self._check_qt_arg_combination(qt_version, os_name, target, arch):
self.logger.warning("Specified target combination is not valid: {} {} {}".format(os_name, target, arch)) self.logger.warning("Specified target combination is not valid: {} {} {}".format(os_name, target, arch))
if not self._check_modules_arg(qt_version, modules): if not self._check_modules_arg(qt_version, modules):
@@ -138,7 +138,7 @@ class Cli():
output_dir = args.outputdir output_dir = args.outputdir
sevenzip = self._set_sevenzip(args) sevenzip = self._set_sevenzip(args)
version = args.version version = args.version
mirror = self._check_mirror(args) mirror = self._check_mirror(args.base)
if not self._check_tools_arg_combination(os_name, tool_name, arch): if not self._check_tools_arg_combination(os_name, tool_name, arch):
self.logger.warning("Specified target combination is not valid: {} {} {}".format(os_name, tool_name, arch)) self.logger.warning("Specified target combination is not valid: {} {} {}".format(os_name, tool_name, arch))
QtInstaller(ToolArchives(os_name, tool_name, version, arch, mirror=mirror, logging=self.logger), QtInstaller(ToolArchives(os_name, tool_name, version, arch, mirror=mirror, logging=self.logger),
@@ -159,7 +159,6 @@ class Cli():
parser.add_argument('--logging-conf', type=argparse.FileType('r'), parser.add_argument('--logging-conf', type=argparse.FileType('r'),
nargs=1, help="Logging configuration ini file.") nargs=1, help="Logging configuration ini file.")
parser.add_argument('--logger', nargs=1, help="Specify logger name") parser.add_argument('--logger', nargs=1, help="Specify logger name")
parser.add_argument('--dry-run', action='store_true', help='Dry run operations.')
subparsers = parser.add_subparsers(title='subcommands', description='Valid subcommands', subparsers = parser.add_subparsers(title='subcommands', description='Valid subcommands',
help='subcommand for aqt Qt installer') help='subcommand for aqt Qt installer')
install_parser = subparsers.add_parser('install') install_parser = subparsers.add_parser('install')
@@ -226,5 +225,4 @@ class Cli():
def run(self, arg=None): def run(self, arg=None):
args = self.parser.parse_args(arg) args = self.parser.parse_args(arg)
self._setup_logging(args) self._setup_logging(args)
self.dry_run = args.dry_run
args.func(args) args.func(args)

View File

@@ -3,7 +3,7 @@ import aqt
def test_cli_help(capsys): def test_cli_help(capsys):
expected = "".join(["show help\n", expected = "".join(["show help\n",
"usage: aqt [-h] [--logging-conf LOGGING_CONF] [--logger LOGGER] [--dry-run]\n", "usage: aqt [-h] [--logging-conf LOGGING_CONF] [--logger LOGGER]\n",
" {install,tool,list,help} ...\n", " {install,tool,list,help} ...\n",
"\n", "\n",
"Installer for Qt SDK.\n", "Installer for Qt SDK.\n",
@@ -13,7 +13,6 @@ def test_cli_help(capsys):
" --logging-conf LOGGING_CONF\n", " --logging-conf LOGGING_CONF\n",
" Logging configuration ini file.\n", " Logging configuration ini file.\n",
" --logger LOGGER Specify logger name\n", " --logger LOGGER Specify logger name\n",
" --dry-run Dry run operations.\n",
"\n", "\n",
"subcommands:\n", "subcommands:\n",
" Valid subcommands\n", " Valid subcommands\n",
@@ -32,3 +31,19 @@ def test_cli_check_module():
assert not cli._check_modules_arg('5.7', ['not_exist']) assert not cli._check_modules_arg('5.7', ['not_exist'])
assert cli._check_modules_arg('5.14.0', None) assert cli._check_modules_arg('5.14.0', None)
assert not cli._check_modules_arg('5.15.0', ["Unknown"]) assert not cli._check_modules_arg('5.15.0', ["Unknown"])
def test_cli_check_combination():
cli = aqt.cli.Cli()
assert cli._check_qt_arg_combination('5.11.3', 'linux', 'desktop', 'gcc_64')
assert cli._check_qt_arg_combination('5.11.3', 'mac', 'desktop', 'clang_64')
assert not cli._check_qt_arg_combination('5.14.0', 'android', 'desktop', 'clang_64')
def test_cli_check_mirror():
cli = aqt.cli.Cli()
assert cli._check_mirror(None)
arg = ['install', '5.11.3', 'linux', 'desktop', '-b', "https://download.qt.io/"]
args = cli.parser.parse_args(arg)
assert args.base == 'https://download.qt.io/'
assert cli._check_mirror(args.base)