Skip to content

Commit

Permalink
(subsitute) Make sur the json entries exists.
Browse files Browse the repository at this point in the history
if ['descriptor'], ['descriptor']['sequence'] or ['descriptor']['info']
does not exists, we create them as empty.
  • Loading branch information
jfkneib authored and neoclust committed Jun 8, 2021
1 parent 04d45c2 commit c8c3bfc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pulse_xmpp_master_substitute/lib/plugins/xmpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5949,9 +5949,19 @@ def updatedeployresultandstate(self, session, sessionid, state, result):
jsonresult = json.loads(result)
except Exception as e:
self.logger.error(str(e))
self.logger.error("error convertion str in string json to dict")
self.logger.error("string %s" % result)
self.logger.error("We failed to convert the result into a json format")
self.logger.error("The string we failed to convert is: %s" % result)
return -1

if 'descriptor' not in jsonresult:
jsonresult['descriptor'] = {}

if 'sequence' not in jsonresult['descriptor']:
jsonresult['descriptor']['sequence'] = {}

if 'info' not in jsonresult['descriptor']:
jsonresult['descriptor']['info'] = {}

jsonautre = copy.deepcopy(jsonresult)
try:
del jsonautre['descriptor']
Expand Down

0 comments on commit c8c3bfc

Please sign in to comment.