yukai / emo-platform-api-python Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
try:
cilent.some_request() # ここで送っているリクエストの内容が後から見れない
except EmoError as e:
print("error: ", e)
print("request:", e.request) # 送ったリクエストの内容
print("code:", e.code)
__init__
で渡せるようにする__init__
で渡せるようにする(個人的に ii. が良さそう)
Traceback
Traceback (most recent call last):
File "cmdline.py", line 140, in <module>
d = room.send_audio_msg(file_path)
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/api.py", line 289, in send_audio_msg
return self.base_client._post(
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/api.py", line 151, in _post
return self._check_http_error(request, update_tokens=update_tokens)
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/api.py", line 116, in _check_http_error
response = request()
File "/home/seb/.local/share/virtualenvs/test-env-NjLHGyVC/lib/python3.8/site-packages/requests/api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/seb/.local/share/virtualenvs/test-env-NjLHGyVC/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/seb/.local/share/virtualenvs/test-env-NjLHGyVC/lib/python3.8/site-packages/requests/sessions.py", line 528, in request
prep = self.prepare_request(req)
File "/home/seb/.local/share/virtualenvs/test-env-NjLHGyVC/lib/python3.8/site-packages/requests/sessions.py", line 456, in prepare_request
p.prepare(
File "/home/seb/.local/share/virtualenvs/test-env-NjLHGyVC/lib/python3.8/site-packages/requests/models.py", line 319, in prepare
self.prepare_body(data, files, json)
File "/home/seb/.local/share/virtualenvs/test-env-NjLHGyVC/lib/python3.8/site-packages/requests/models.py", line 512, in prepare_body
(body, content_type) = self._encode_files(files, data)
File "/home/seb/.local/share/virtualenvs/test-env-NjLHGyVC/lib/python3.8/site-packages/requests/models.py", line 122, in _encode_files
raise ValueError("Data must not be a string.")
ValueError: Data must not be a string.
Client._post
の data
をstrからdictに変更すると直しますが、これは別の影響があるか分からないので確認お願いします。
json優先方式だと、アカウントを切り替えたいときに環境変数の操作だけでは、切り替えることができなくなっている
フロー
再現は今の所1回だけです。
確定ではないですが、Audio file送信の時トークンリフレッシュが行ったことにみえて、以下のエラーが起きました。
すぐ後に同じコードを実行したら成功しました。
Traceback (most recent call last):
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/exceptions.py", line 56, in http_error_handler
yield None
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/api.py", line 119, in _check_http_error
response.raise_for_status()
File "/home/seb/.local/share/virtualenvs/test-env-NjLHGyVC/lib/python3.8/site-packages/requests/models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://platform-api.bocco.me/v1/rooms/344293fc-7738-45d4-ba6c-998283c0b6de/messages/audio
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/api.py", line 119, in _check_http_error
response.raise_for_status()
File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/exceptions.py", line 59, in http_error_handler
raise http_exception(e.response.json())
emo_platform.exceptions.UnauthorizedError: {'code': 'unauthorized', 'reason': 'JWT token is expired.'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/exceptions.py", line 56, in http_error_handler
yield None
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/api.py", line 126, in _check_http_error
response.raise_for_status()
File "/home/seb/.local/share/virtualenvs/test-env-NjLHGyVC/lib/python3.8/site-packages/requests/models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://platform-api.bocco.me/v1/rooms/344293fc-7738-45d4-ba6c-998283c0b6de/messages/audio
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "cmdline.py", line 140, in <module>
d = room.send_audio_msg(file_path)
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/api.py", line 289, in send_audio_msg
return self.base_client._post(
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/api.py", line 151, in _post
return self._check_http_error(request, update_tokens=update_tokens)
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/api.py", line 126, in _check_http_error
response.raise_for_status()
File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/home/seb/Documents/yukai/bemo/platform-api/repository/emo-platform-api-python/emo_platform/exceptions.py", line 59, in http_error_handler
raise http_exception(e.response.json())
emo_platform.exceptions.BadRequestError: {'audio': 'must not be null'}
ColorとHeadの値は制限ありますので、正しくない場合はExceptionをあがると良いかも。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.