Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def patch(self, url, body):
headers = self._headers_send_json()
return self.request(url, HTTPMethod.PATCH, headers, {},
self._obj_to_json(body))
def update(self, stream_id, stream_update):
return self._update(self._base(stream_id), HTTPMethod.PATCH, requests.codes.ok, stream_update, self.streamDesc)
def _update(self, url, method, success_code, obj_update, obj_desc):
if method == HTTPMethod.PUT:
response = self.transport.put(url, obj_update)
elif method == HTTPMethod.PATCH:
response = self.transport.patch(url, obj_update)
if response.status_code == success_code:
if str(response.text) == '':
return
else:
obj = response.json()
self.print_json("Updated", obj)
return obj
else:
self.logger.debug("Error updating " + obj_desc + ": "
+ self.transport.dump_response(response))
raise Exception("Error updating " + obj_desc + ": "
+ response.text)