Skip to content

Commit

Permalink
Merge pull request #7365 from chaen/v8.0_FIX-accountingJson
Browse files Browse the repository at this point in the history
fix (WLCG Json accounting): make sure the file we download is json
  • Loading branch information
fstagni committed Dec 11, 2023
2 parents e9d5937 + 56732f2 commit 07037d0
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def _downloadJsonFile(self, occupancyLFN, filePath):
continue
occupancyURL = res["Value"]
ctx.filecopy(params, occupancyURL, "file://" + filePath)
# Just make sure the file is json, and not SSO HTML
with open(filePath) as f:
json.load(f)

return
except gfal2.GError as e:
detailMsg = "Failed to copy file %s to destination url %s: [%d] %s" % (
Expand All @@ -54,6 +58,9 @@ def _downloadJsonFile(self, occupancyLFN, filePath):
)
self.log.debug("Exception while copying", detailMsg)
continue
except json.decoder.JSONDecodeError as e:
self.log.debug("Downloaded file is not json")
continue

def getOccupancy(self, **kwargs):
"""Returns the space information given by WLCG Accouting Json
Expand Down

0 comments on commit 07037d0

Please sign in to comment.