-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add Files class for upload/download files #781
base: master
Are you sure you want to change the base?
Conversation
except TimeoutError as err: | ||
raise FilesError("Timeout reached while trying to download file") from err | ||
except ClientError as err: | ||
raise FilesError("Failed to download file") from err |
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.
Maybe include the response status code in the error message? Ie catch ClientResponseError
separately and then ClientError
. For the ClientError
case maybe include the exception in the message string?
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.
Not suited for MVP.
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.
Adding the exception to the message for ClientError
is just a change on this line.
resp.url.path if resp.url.host == self._cloud.servicehandlers_server else "" | ||
) | ||
_LOGGER.log( | ||
logging.DEBUG if isok else logging.WARNING, |
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'd include these details in the exception message and let consumers decide how to log it. Ie always log only at debug level here.
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.
Not suited for MVP.
if data is None: | ||
raise FilesError("Failed to parse response from files handler") from None | ||
|
||
resp.raise_for_status() |
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.
Shouldn't we raise before we try parsing the response?
Adds a new
Files
class to handle the communication related to files.Eventually, all file-related functions would be moved into this new class.
But as a start, it now contains the upload and download handling.
Cleaning up the old stuff will be done in a separate PR.