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

errors out during weather request #1

Open
jfancherla opened this issue May 7, 2019 · 5 comments
Open

errors out during weather request #1

jfancherla opened this issue May 7, 2019 · 5 comments

Comments

@jfancherla
Copy link

Running SDK 1.6 on MacOS 10.14.4

The feed parser command did not work so I changed it to:
python3 -m pip install feedparser

feedparser installed successfully

first run it errored after a few seconds:

raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

second run was longer but then:

File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

@TurkMcGill
Copy link
Owner

TurkMcGill commented May 8, 2019

I'm VERY new to Python, so to be honest I'm not sure what the '-m' does during an install. I'm pretty sure I installed feedparser by simply doing: "pip install feedparser" (But I suspect the install is not the cause of your problem.)

Did you put apis.py and config.py in the same folder as the program? Did you modify config.py after you downloaded it? Can you see if the unmodified file works?

I wrote Vectorator on a Windows 10 machine and haven't tested it on a Mac. The OS might have something to do with it, as well. I'll see what I can find out.

@ramillsjr
Copy link

Is there a preference for formatting the weather location in the cofig.py file?
I initially entered: loc_city = "Paw Paw" loc_region = "Michigan"
Vectorator.py stopped: File "C:\Program Files\Python36\lib\urllib\request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad request

Here's the output from my terminal from the weather request:
Adding 163 seconds to random_weather.
Traceback (most recent call last):
File "vectorator.py", line 439, in
vector_react(reaction[0])
File "vectorator.py", line 197, in vector_react
say(arg)
File "vectorator.py", line 212, in say
if arg_name == "random_weather": to_say = get_weather("random_weather") # Randomly announce a weather fact
File "vectorator.py", line 271, in get_weather
data = urllib.request.urlopen(url).read()
File "C:\Program Files\Python36\lib\urllib\request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "C:\Program Files\Python36\lib\urllib\request.py", line 532, in open
response = meth(req, response)
File "C:\Program Files\Python36\lib\urllib\request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Program Files\Python36\lib\urllib\request.py", line 570, in error
return self._call_chain(*args)
File "C:\Program Files\Python36\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "C:\Program Files\Python36\lib\urllib\request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad request

I've update the config.py to be: loc_city = "Paw Paw" loc_region = "MI" to see with this also causes a duplicate HTTP error 400

@TurkMcGill
Copy link
Owner

Yeah, I tried it out this morning and your city and state are definitely the cause of this problem. I'm using the free version of the open weather API: https://openweathermap.org/api and if you search for "Paw Paw" on their website it finds several city names in the US, but returns no results for "Paw Paw, Michigan". Strange.

I may just have to catch the error and prompt people to pick a larger city in the area...

@ramillsjr
Copy link

I changed the location. to Kalamazoo US and vectorator properly queries the API.

V3D9 has been running since this morning delivering weather information.

@jfancherla
Copy link
Author

Sometimes it will run for a while before it goes looking for weather data. I got the message about the "Paw Paw" error and changed the config file so it asks for Los Angeles rather than San Pedro. Still no joy.
I tried going to the default config file and that seemed to work as I got weather data for Berlin. But when I edited the file to Los Angeles and California it errored out on weather

Adding 8000 seconds to news_intro.
Traceback (most recent call last):
File "vectorator.py", line 408, in
vector_react("news_intro")
File "vectorator.py", line 197, in vector_react
say(arg)
File "vectorator.py", line 208, in say
if arg_name == "news_intro": to_say = to_say + get_news() + get_weather("forecast") # if news then add to end of intro
File "vectorator.py", line 271, in get_weather
data = urllib.request.urlopen(url).read()
File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad request

So I changed the location to Sacramento and that seemed to work so I think the URL parser is having trouble with spaces. Not sure if it is on the sending end or the receiving end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants