Add logging and file list processing #65
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements
logging
moduleurl error_code
io.download()
to allow downloading from a txt file (such as an error log) any list of URLs where the first entry in each line is a URL can be used to download URLs from a file.INFO
which means that the progressbar is shown and errors will be shown.stats = io.download()
now returns the statistics of success/failed/skipped filesremaining issues
Functionality
Resuming
instead of implementing a complicated resume system, we just rely on
overwrite=False
which prevents files being downloaded again. As we use hashes of the URLs, this should impose any problems and should be still very fast since no additional queries are being made.example:
running
download = gbif_dl.io.download(queries, overwrite=False)
multiple times would automatically resume as the files that are already on disk will be skipped.Logging
Furthermore we now provide a way to redirect the output of the download progress.
std.err
std.out
So a (Linux) user could do:
the file might look like this
to redirect the list of failed URLs to a file.
Conveniently, this PR also implements a way to download a list of URLs from a text :
For non-unix users, this PR added a way to directly log to a file without using pipes:
Error logging and the progress bar can now be turned off using standard log levels (instead of
verbose=True
which was removed)