Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggested fixes by iCR, OpenRefactory, Inc. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

def get_weather():
url = "http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&clientType=android&sign=android&city=" + city
res = requests.get(url).json()
# OpenRefactory Warning: The 'requests.get' method does not use any 'timeout' threshold which may cause program to hang indefinitely.
res = requests.get(url, timeout=100).json()
weather = res['data']['list'][0]
return weather['weather'], math.floor(weather['temp'])

Expand All @@ -35,7 +36,8 @@ def get_birthday():
return (next - today).days

def get_words():
words = requests.get("https://api.shadiao.pro/chp")
# OpenRefactory Warning: The 'requests.get' method does not use any 'timeout' threshold which may cause program to hang indefinitely.
words = requests.get("https://api.shadiao.pro/chp", timeout=100)
if words.status_code != 200:
return get_words()
return words.json()['data']['text']
Expand Down