Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dingtalk_stream/card_replier.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def create_and_send_card(self,

response.raise_for_status()
except Exception as e:
self.logger.error('CardResponder.send_card failed, create card instance failed, error=%s', e)
self.logger.error(f'CardResponder.send_card failed, create card instance failed, error={e}, response.text={response.text}')
return ""

body = {
Expand Down Expand Up @@ -165,7 +165,7 @@ def create_and_send_card(self,

return card_instance_id
except Exception as e:
self.logger.error('put_card_data.create_and_send_card failed, send card failed, error=%s', e)
self.logger.error(f'put_card_data.create_and_send_card failed, send card failed, error={e}, response.text={response.text}')
return ""

def put_card_data(self, card_instance_id: str, card_data: dict, **kwargs):
Expand Down Expand Up @@ -199,7 +199,7 @@ def put_card_data(self, card_instance_id: str, card_data: dict, **kwargs):

response.raise_for_status()
except Exception as e:
self.logger.error('CardReplier.put_card_data failed, update card failed, error=%s', e)
self.logger.error(f'CardReplier.put_card_data failed, update card failed, error={e}, response.text={response.text}')
return


Expand Down Expand Up @@ -293,5 +293,5 @@ def streaming(self, card_instance_id: str, content_key: str, content_value: str,

response.raise_for_status()
except Exception as e:
self.logger.error('AICardReplier.streaming failed, error=%s', e)
self.logger.error(f'AICardReplier.streaming failed, error={e}, response.text={response.text}')
return
12 changes: 6 additions & 6 deletions dingtalk_stream/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def get_image_download_url(self, download_code: str) -> str:

response.raise_for_status()
except Exception as e:
self.logger.error('get_image_download_url, error=%s, response=%s', e, response.text)
self.logger.error(f'get_image_download_url, error={e}, response.text={response.text}')
return ""
return response.json()["downloadUrl"]

Expand Down Expand Up @@ -607,7 +607,7 @@ def set_off_duty_prompt(self, text: str, title: str = "", logo: str = ""):

response.raise_for_status()
except Exception as e:
self.logger.error('set_off_duty_prompt, error=%s, response=%s', e, response.text)
self.logger.error(f'set_off_duty_prompt, error={e}, response.text={response.text}')
return response.status_code
return response.json()

Expand All @@ -633,7 +633,7 @@ def reply_text(self,
data=json.dumps(values))
response.raise_for_status()
except Exception as e:
self.logger.error('reply text failed, error=%s', e)
self.logger.error(f'reply text failed, error={e}, response.text={response.text}')
return None
return response.json()

Expand Down Expand Up @@ -661,7 +661,7 @@ def reply_markdown(self,
data=json.dumps(values))
response.raise_for_status()
except Exception as e:
self.logger.error('reply markdown failed, error=%s', e)
self.logger.error(f'reply markdown failed, error={e}, response.text={response.text}')
return None
return response.json()

Expand Down Expand Up @@ -742,7 +742,7 @@ def reply_card(self,

return card_biz_id
except Exception as e:
self.logger.error('reply card failed, error=%s', e)
self.logger.error(f'reply card failed, error={e}, response.text={response.text}')
return ""

def update_card(self, card_biz_id: str, card_data: dict):
Expand Down Expand Up @@ -778,7 +778,7 @@ def update_card(self, card_biz_id: str, card_data: dict):
data=json.dumps(values))
response.raise_for_status()
except Exception as e:
self.logger.error('update card failed, error=%s, response=%s', e, response.text)
self.logger.error(f'update card failed, error={e}, response.text={response.text}')
return response.status_code
return response.json()

Expand Down
8 changes: 3 additions & 5 deletions dingtalk_stream/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,13 @@ def open_connection(self):
'localIp': self.get_host_ip()
}).encode('utf-8')

http_body = None
try:
response = requests.post(DingTalkStreamClient.OPEN_CONNECTION_API,
headers=request_headers,
data=request_body)
http_body = response.json()
response.raise_for_status()
except Exception as e:
self.logger.error("open connection failed, error=%s, response.body=%s", e, http_body)
self.logger.error(f'open connection failed, error={e}, response.text={response.text}')
return None
return response.json()

Expand Down Expand Up @@ -200,7 +198,7 @@ def get_access_token(self):
data=json.dumps(values))
response.raise_for_status()
except Exception as e:
self.logger.error('get dingtalk access token failed, error=%s', e)
self.logger.error(f'get dingtalk access token failed, error={e}, response.text={response.text}')
return None

result = response.json()
Expand All @@ -227,7 +225,7 @@ def upload_to_dingtalk(self, image_content, filetype='image', filename='image.pn
self.reset_access_token()
response.raise_for_status()
except Exception as e:
self.logger.error('upload to dingtalk failed, error=%s', e)
self.logger.error(f'upload to dingtalk failed, error={e}, response.text={response.text}')
return None
if 'media_id' not in response.json():
self.logger.error('upload to dingtalk failed, error resonse is %s', response.json())
Expand Down
2 changes: 1 addition & 1 deletion dingtalk_stream/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION_STRING = '0.17.2'
VERSION_STRING = '0.17.3'