- #endpoint = '{}{}'.format(self._apiBase,ow_string)
- http_code, resp = self._http.post_cmd(endpoint=endpoint, postfields_dict=pdu)
- #print('HTTP CODE: {}'.format(http_code))
- #print('RESP: {}'.format(resp))
- if http_code in (200, 201, 202, 204):
- if resp:
- resp = json.loads(resp)
- if not resp or 'id' not in resp:
- raise ClientException('unexpected response from server: '.format(
- resp))
- print(resp['id'])
- else:
- msg = "Error {}".format(http_code)
- if resp:
- try:
- msg = "{} - {}".format(msg, json.loads(resp))
- except ValueError:
- msg = "{} - {}".format(msg, resp)
- raise ClientException("failed to create/update pdu - {}".format(msg))
+ # endpoint = '{}{}'.format(self._apiBase,ow_string)
+ http_code, resp = self._http.post_cmd(
+ endpoint=endpoint, postfields_dict=pdu
+ )
+ # print('HTTP CODE: {}'.format(http_code))
+ # print('RESP: {}'.format(resp))
+ # if http_code in (200, 201, 202, 204):
+ if resp:
+ resp = json.loads(resp)
+ if not resp or "id" not in resp:
+ raise ClientException("unexpected response from server: {}".format(resp))
+ print(resp["id"])
+ # else:
+ # msg = "Error {}".format(http_code)
+ # if resp:
+ # try:
+ # msg = "{} - {}".format(msg, json.loads(resp))
+ # except ValueError:
+ # msg = "{} - {}".format(msg, resp)
+ # raise ClientException("failed to create/update pdu - {}".format(msg))