Commit Graph

105 Commits

Author SHA1 Message Date
David Dalcino
dc45839df4 Fix implementation of helper.get_hash
Causes `get_hash` to verify the hash length, and check that the hash can
be unhexlified properly.

Fixes the interface for `get_hash` so that the caller does not have to
run `binascii.unhexlify` or verify its output.
2022-03-20 14:16:24 -07:00
David Dalcino
6bd438bcb1 Use secrets for secure random numbers 2022-03-10 17:35:30 -08:00
David Dalcino
5ad7c1a058 Use defusedxml to parse Updates.xml files
I don't think we can really call the `Updates.xml` files that we are
parsing 'untrusted xml', because we are checking that they match the
sha256 checksum. However, I don't think there's any good reason not to
use a more secure parsing algorithm.
2022-03-10 17:23:58 -08:00
David Dalcino
b62db9ee2a Allow MetadataFactory.fetch_http to skip sha256
`MetadataFactory.fetch_http` must often download HTML pages, not
Updates.xml files. download.qt.io does not store checksums for these
files, so this particular function must be allowed to download these
pages without using a checksum.
2022-03-06 18:16:37 -08:00
David Dalcino
5a7adb60cf Check hashes for xml files 2022-03-06 17:56:26 -08:00
David Dalcino
d6a6f79740 Prevent listing modules <= 40 bytes uncompressed
This prevents `list-*` from printing any module whose uncompressed size
is 40 bytes or less.

I have found a couple of modules that are exactly 40 bytes, and they
include no files, only empty directories. If any user tries to install
these modules, they will think that aqt failed to install the module
without printing any error message. I prefer to avoid this issue
by preventing `aqt list-*` from printing them.

`aqt install-*` is unaffected by this change, and it can still install
modules that contain no files. It is likely that we will need to print
a warning when this occurs.

If any user disagrees with the threshold value of 40 bytes, they are
free to adjust that value to their liking in `settings.ini`.
2021-11-26 14:04:10 -08:00
David Dalcino
e6cd276e20 Add impl of list-src/doc/examples 2021-11-23 11:08:11 -08:00
David Dalcino
a30bab6bc4 Add debug message when fallback url used 2021-10-27 22:28:24 -07:00
David Dalcino
7104dbcdf7 Merge remote-tracking branch 'upstream/master' into add-list-qt-archives 2021-09-20 18:49:46 -07:00
David Dalcino
f78013d361 Improve suggested follow-up for --modules flag 2021-09-17 16:14:49 -07:00
David Dalcino
5b29fec26d black 2021-09-17 15:09:09 -07:00
David Dalcino
64e38deda8 Add passing implementation of fetch_modules 2021-09-17 14:50:13 -07:00
David Dalcino
253ff50845 Refactor xml fetch methods for easier reuse 2021-09-17 14:50:13 -07:00
David Dalcino
7f256a252c Add interface to fetch modules 2021-09-17 14:49:05 -07:00
David Dalcino
f037a96457 Raise ArchiveListError where appropriate 2021-09-17 09:53:35 -07:00
David Dalcino
4099b75121 black 2021-09-17 08:32:49 -07:00
David Dalcino
49cde4ee30 fix test error 2021-09-17 08:32:49 -07:00
David Dalcino
2318ca6a61 sort output 2021-09-17 08:32:49 -07:00
David Dalcino
b888cab8e4 add arguments length check 2021-09-17 08:32:48 -07:00
David Dalcino
8cc7979f46 Add suggested follow up for archives flag 2021-09-17 08:32:48 -07:00
David Dalcino
709f064ebb Implement fetch_archives 2021-09-17 08:32:40 -07:00
David Dalcino
3c15c56188 Refactor xml fetch methods for easier reuse 2021-09-17 08:31:25 -07:00
David Dalcino
1a918c35c5 Merge remote-tracking branch 'upstream/master' into specify-version-by-simplespec 2021-09-09 08:26:10 -07:00
Hiroshi Miura
320a20abb2 Merge pull request #385 from ddalcino/improve-error-handling
Improve error handling
2021-09-08 15:46:17 +09:00
David Dalcino
5a1aedb480 Add functions to determine extensions
This moves the logic for determining extensions out of the QtArchive
class so that it is available elsewhere and does not need to be
duplicated.
2021-09-07 14:27:51 -07:00
David Dalcino
88c30d90d0 Raise exceptions from existing exceptions 2021-09-02 09:57:34 -07:00
David Dalcino
a380f5c1ea Allow list-qt to describe Qt 6.2 wasm target
On August 19, the Qt repo added a new wasm release for Qt 6.2.0.
`list-qt` currently prints that the `wasm` extension is available for
that version of Qt, but it will not let the user use it to query
modules and architectures, because of a hardcoded version check.
This change rewrites the version check so that a user may make queries.
2021-09-01 13:38:09 -07:00
David Dalcino
f63fcc5c79 Add AqtException base exception class
This also moves the `format_suggested_follow_up` function into the new
AqtException class, refactors `show_list` to use the new exceptions,
and tests the new code appropriately.
2021-09-01 11:42:45 -07:00
David Dalcino
17dc333787 strip addons. prefix from list-qt --modules 2021-08-18 10:18:27 -07:00
Hiroshi Miura
c99ec5372b Coding style update by Black/isort
Change to max line length to 125

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-08-02 13:50:00 +09:00
David Dalcino
1b6b3bcf86 Shorten SimpleSpec.usage string
If users need more complicated SimpleSpecs, they can read the docs linked above
2021-07-23 23:03:09 -07:00
David Dalcino
08a0ad0182 Add test, impl for optional 'tools_' prefix 2021-07-22 11:36:06 -07:00
David Dalcino
c37e09a8d5 Add type hints 2021-07-22 09:53:24 -07:00
David Dalcino
e9d1b52ac8 Remove unnecessary version mismatch checker 2021-07-22 09:53:24 -07:00
David Dalcino
f02e12eb8f fix MetadataFactory list-tool function 2021-07-22 09:53:23 -07:00
David Dalcino
a52214144c fix ArchiveId.to_url bug related to category 2021-07-22 09:53:23 -07:00
David Dalcino
8aa7af2524 Add new syntax to installer.Cli 2021-07-22 09:53:22 -07:00
David Dalcino
767b8d4bf2 Fix output strings 2021-07-22 09:53:22 -07:00
David Dalcino
d5f1c9487c Replace MetadataFactory.filter_minor with spec 2021-07-22 09:53:07 -07:00
David Dalcino
75007fa60f isort again 2021-07-18 19:34:42 -07:00
David Dalcino
e49c64bdcf remove unused imports 2021-07-18 19:28:46 -07:00
David Dalcino
2707ea108a Shift logging responsibility to caller
This allows the tests to run successfully, without interference from
the logger.
2021-07-18 19:23:33 -07:00
David Dalcino
bf196bb0ba Replace Callable with log_level
This allows the caller to pass a log level to the suggestions printer,
rather than a Callable.
2021-07-18 18:40:32 -07:00
David Dalcino
7b6af69645 Merge remote-tracking branch 'upstream/master' into refactor-show_suggestions
# Conflicts:
#	aqt/metadata.py
2021-07-18 02:19:48 -07:00
David Dalcino
0739629070 Refactor show_suggestion out of show_list & test 2021-07-18 02:16:37 -07:00
David Dalcino
55b858afc3 Refactor suggested_follow_up
This alters `suggested_follow_up` to return a list of strings.
This makes testing easier, as well as making it easier to change the
way the suggestions are displayed.

This change also fixes an error in the suggestions ('list' was missing
from the suggested command), and fixes some punctuation errors.

This also adds a print formatter that displays the suggestions nicely
in the terminal.
2021-07-18 01:39:25 -07:00
David Dalcino
72ef17c7b1 Rename aqt.list logger to aqt.metadata
This follows the convention set out by the rest of the project, where
the loggers are all named after the files in which they are used.
2021-07-18 01:34:28 -07:00
David Dalcino
4b82a08012 Add Versions.flattened(): return full list
`Versions.flattened()` returns a flat list of all the versions in the
Versions object, without any stratification by minor version.

This commit also updates the type hint for Versions.__iter__, which
returns a Generator.
2021-07-16 15:17:03 -07:00
Hiroshi Miura
da29dbfbc1 Handle notty case
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-15 17:53:24 +09:00
Hiroshi Miura
cf7aefd10c Change short listing of long tool option
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-15 13:23:56 +09:00