Skip to content

Commit

Permalink
refactor: replace json.loads(result.content) with result.json()
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Aug 27, 2024
1 parent a20741d commit e5e9c0d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions osm_fieldwork/OdkCentral.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ def getSubmissionPhoto(
if result.status_code == 200:
log.debug(f"fetched {filename} from Central")
else:
status = json.loads(result.content)
status = result.json()
log.error(f"Couldn't fetch {filename} from Central: {status['message']}")
return result.content

Expand Down Expand Up @@ -957,7 +957,7 @@ def uploadMedia(
url = f"{self.base}projects/{projectId}/forms/{form_name}/draft?ignoreWarnings=true"
result = self.session.post(url, verify=self.verify)
if result.status_code != 200:
status = json.loads(result.content)
status = result.json()
log.error(f"Couldn't modify {form_name} to draft: {status['message']}")
return None

Expand All @@ -971,7 +971,7 @@ def uploadMedia(
if result.status_code == 200:
log.debug(f"Uploaded {filename} to Central")
else:
status = json.loads(result.content)
status = result.json()
log.error(f"Couldn't upload {filename} to Central: {status['message']}")
return None

Expand Down Expand Up @@ -1007,7 +1007,7 @@ def getMedia(
if result.status_code == 200:
log.debug(f"fetched {filename} from Central")
else:
status = json.loads(result.content)
status = result.json()
log.error(f"Couldn't fetch {filename} from Central: {status['message']}")
self.addMedia(result.content, filename)
return self.media
Expand Down Expand Up @@ -1166,7 +1166,7 @@ def publishForm(
url = f"{self.base}projects/{projectId}/forms/{xform}/draft/publish?version={version}"
result = self.session.post(url, verify=self.verify)
if result.status_code != 200:
status = json.loads(result.content)
status = result.json()
log.error(f"Couldn't publish {xform} on Central: {status['message']}")
else:
log.info(f"Published {xform} on Central.")
Expand Down

0 comments on commit e5e9c0d

Please sign in to comment.