fictive-kin / fl33t-client Goto Github PK
View Code? Open in Web Editor NEWFl33t Firmware Service Python API Client
Home Page: https://fl33t.readthedocs.io/
License: MIT License
Fl33t Firmware Service Python API Client
Home Page: https://fl33t.readthedocs.io/
License: MIT License
I have a few situations where I perform the equivalent of a create-or-get operation, e.g.
try:
device = fleet.create_device(device_id='foobar', name='My Great Device', fleet_id='xxx')
except DuplicateDeviceIdError:
device = fleet.service.get_device(device_id='foobar')
which works as expected. However, even though I capture and handle the DuplicateDeviceIdError
, an exception log is emitted:
409 Client Error: Conflict for url: https://api.fl33t.com/team/<teamid>/device
Traceback (most recent call last):
File "[…redacted…]/lib/python3.6/site-packages/fl33t/client.py", line 275, in _request
result.raise_for_status()
File "[…redacted…]/lib/python3.6/site-packages/requests/models.py", line 939, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 409 Client Error: Conflict for url: https://api.fl33t.com/team/<teamid>/device
This was confusing, since the operation succeeded (from my point of view), but there was still an exception log generated.
The pertinent section in the code is: https://github.com/fictivekin/fl33t-client/blob/2cc44267bb7e3919fd71f46ebc8772c4d439be74/fl33t/client.py#L273-L287
Where if an HTTPError
is raised from requests
, it is unconditionally logged. This affects the device creation logic: https://github.com/fictivekin/fl33t-client/blob/2cc44267bb7e3919fd71f46ebc8772c4d439be74/fl33t/models/device.py#L134-L136
in that the log is emitted, and the DuplicateDeviceIdError
exception is raised.
I propose that exceptions are logged only if they are not explicitly re-raised as a different, client-specific exception.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.