-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client refactor: code reformatting #1341
Client refactor: code reformatting #1341
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks mostly good to me:
- disagree with logging-not-lazy (we can discuss though)
- The *_target_download() functions still make me itch -- whatever we do here let's next concentrate on getting those fixed
tuf/client_rework/updater_rework.py
Outdated
for temp_obj in mirrors._mirror_target_download( | ||
target, self._mirrors, self._fetcher | ||
): | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit message says it only moves code but this obviously changes things... We already have an issue on figuring out the download methods design (and fixing the bugs it has with multiple mirrors) so I'm not expecting this commit to fix everything -- but I also don't understand what this change does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this, it was a mistake after cherry-picking this commit from another branch.
I had to rebase and force push to fix this. This is the new commit: 35587c4
tuf/client_rework/download.py
Outdated
msg = f"Downloading: {url}" | ||
logger.info(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with the whole logging-not-lazy commit: Working around warning like this is not useful.
- if we want to use f-strings with logging, let's silence the warning in the linter config
- alternatively, let's just use %-style strings (I lean this way)
tuf/client_rework/mirrors.py
Outdated
@@ -110,7 +99,7 @@ def get_list_of_mirrors(file_type, file_path, mirrors_dict): | |||
in_confined_directory = securesystemslib.util.file_in_confined_directories | |||
|
|||
list_of_mirrors = [] | |||
for dummy, mirror_info in six.iteritems(mirrors_dict): | |||
for dummy, mirror_info in mirrors_dict.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: dummy is not even required for mirror_info in mirrors_dict.values()
tuf/client_rework/download.py
Outdated
import logging | ||
import tempfile | ||
import timeit | ||
import urllib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from urllib import parse
maybe -- and then use parse.unquote() etc. Current code only works by accident since some other module happens to import the right thing
The modules performing network download are used only by the client side of TUF. Move them inside the client directory for the refactored client. Move the _mirror_*download functions from Updater to mirrors.py. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
The two functions safe/unsafe_download differ only by setting a single boolean flag. Remove them and call directly _download_file instead. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
Run black and isort over the old modules which were moved inside the client directory: - download.py - fetcher.py - mirrors.py - requests_fetcher.py Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
Fix line lenght exceeding 80 characters since the black formatter does not wrap lines inside comments. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
Fix "Access to a protected member _mirror_target_download, _mirror_meta_download of a client class" Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
- fix C0103 invalid argument name STRICT_REQUIRED_LENGTH - use 'dummy' as an accepted by pylint unused variable name (W0612) Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
pylint cannot figure out that we store the exceptions in a dictionary to raise them later so we disable the warning. This should be reviewed in the future still. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
six and future are Python 2 compatibility modules which are no longer needed after the end of Python 2 support. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
Fix imports to be vendoring compatible. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
Disable pylint's "Use lazy % formatting in logging functions" warning until a common logging approach is decided. See theupdateframework#1334. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
f959bc5
to
101ab3d
Compare
Force pushed the new commits. The differences are in
I chose the lazy way of just ignoring the logging warning now, since there is already an issue capturing the need of a decision: #1334 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
The issues left IMO are:
- download implementation is fishy
- the internal file locations may not be final (I think they should be in _internal/ or something)
but we have these in writing already.
So let's go with this and see where we end up :)
Description of the changes being introduced by the pull request:
Please verify and check that the pull request fulfills the following
requirements: