-
Notifications
You must be signed in to change notification settings - Fork 79
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
Created a function to get submission photo by its submission id #284
Conversation
for more information, see https://pre-commit.ci
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.
It would be really nice if this included a test too 😁
But not essential if it will take lots of time 👍
osm_fieldwork/OdkCentral.py
Outdated
if result.status_code == 200: | ||
log.debug(f"fetched {filename} from Central") | ||
else: | ||
status = eval(result._content) |
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.
It's generally a bad idea to use eval
in Python - there is almost always a better way!
Also accessing a private method is generally bad too.
Can this be achieved using .json() or another method?
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.
In getMedia
func too eval was used, so I thought to use the same, but you are right, eval
is not always a safe option. will refactor for both functions.
how to use dummy submission photo? |
You could possibly just upload some known bytes, not an actual photo:
I assume uploading this with a Then when you check the download data, Of course, the alternative is to include an actual (lightweight) |
Tests aren't essential here, just a nice to have! We can merge this - bump to remind myself! |
thanks for reminding! |
I'll merge this for the next release 👍 If we have tests in future, they don't need to be in a release, just present on |
Updates:
This PR updates the
OdkCentral
creating a new functiongetSubmissionPhoto
to get the photo content from the individual submission.