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

Yahoo weather APIs EOL #1973

Closed
suoto opened this issue Jan 8, 2019 · 31 comments · Fixed by #2038
Closed

Yahoo weather APIs EOL #1973

suoto opened this issue Jan 8, 2019 · 31 comments · Fixed by #2038

Comments

@suoto
Copy link

suoto commented Jan 8, 2019

Noticed that the weather segments disappeared, checked powerline log which contained

2019-01-08 12:28:22,330:ERROR:tmux:WeatherSegment:Exception while computing state for 'London,United Kingdom,GB': <urlopen error [Errno -5] No address associated with hostname>

It seems that the URL powerline uses is no longer supported by Yahoo since
03/Jan
:

Important EOL Notice: As of Thursday, Jan. 3, 2019, the weather.yahooapis.com and query.yahooapis.com for Yahoo Weather API will be retired.

To continue using our free Yahoo Weather APIs, use https://weather-ydn-yql.media.yahoo.com/forecastrss. Contact yahoo-weather-ydn-api@oath.com for credentials to onboard to this free Yahoo Weather API service.

For the record, here's the relevant section of the log

2019-01-08 12:28:22,330:ERROR:tmux:WeatherSegment:Exception while computing state for 'London,United Kingdom,GB': <urlopen error [Errno -5] No address associated with hostname>
Traceback (most recent call last):
  File "/home/souto/.local/lib/python3.6/site-packages/powerline/lib/threaded.py", line 197, in render
    update_state = queries[key][1]
KeyError: 'London,United Kingdom,GB'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.6/socket.py", line 704, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -5] No address associated with hostname

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/souto/.local/lib/python3.6/site-packages/powerline/lib/threaded.py", line 220, in update_one
    updates[key] = (monotonic(), self.compute_state(key))
  File "/home/souto/.local/lib/python3.6/site-packages/powerline/segments/common/wthr.py", line 140, in compute_state
    raw_response = urllib_read(url)
  File "/home/souto/.local/lib/python3.6/site-packages/powerline/lib/url.py", line 15, in urllib_read
    return urlopen(url, timeout=10).read().decode('utf-8')
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -5] No address associated with hostname>

I couldn't find any issue describing this, apologies is it's duplicate.

@mp1118
Copy link

mp1118 commented Feb 1, 2019

It would be straightforward to write a new segment using the OpenWeatherMap API but as far as I can tell this repo seems abandoned. I'd be willing to work on the segment if an admin could reply and confirm that the repo is active and that they'd be willing to merge it.

@gsusrafael
Copy link
Contributor

We can start with a pull request to move the API, i'm available if you need more hands to code this...

@barra51
Copy link

barra51 commented Feb 28, 2019

One more hand here if any help is need to migrate the API

@gsusrafael
Copy link
Contributor

@barra51 @mp1118 when do we start?

@barra51
Copy link

barra51 commented Mar 12, 2019

@gsusrafael For me, it's OK if we start right now :)

@gsusrafael
Copy link
Contributor

i've forked the repo, i'm checking this info https://blog.rapidapi.com/access-global-weather-data-with-these-weather-apis/ to check our options for a Weather Info Gathering....

@liketechnik
Copy link

Just wanted to throw in https://wttr.in as another option, because of it's simplicity

@gsusrafael
Copy link
Contributor

@liketechnik your suggestion is even better... i think could be a painless transition

@gsusrafael
Copy link
Contributor

@liketechnik the only thing i'm still looking for in wttr.in is the posibility to dump the info in JSON...

@liketechnik
Copy link

I'm not sure if this is possible with wttr.in :/ What I found in the Readme is the possibility of having custom formatting and returning the current weather in a single line (https://github.com/chubin/wttr.in#one-line-output)

@gsusrafael
Copy link
Contributor

gsusrafael commented Mar 15, 2019 via email

@USA-RedDragon
Copy link

https://github.com/USA-RedDragon/powerline/commit/352bf96335d0ebd63acc996316af94b1394c8595

Implemented crappy support for Wttr.in. Ideally, we'd use a more professional api that is configurable and more verbose, but this works as an "at a glance" weather feature.

Screen Shot 2019-03-17 at 6 05 06 AM

@gsusrafael
Copy link
Contributor

gsusrafael commented Mar 17, 2019 via email

@kierun
Copy link
Contributor

kierun commented Jun 20, 2019

Any update on this?

@shellclear
Copy link

shellclear commented Jul 21, 2019

it seems @gsusrafael @USA-RedDragon made some progress with wttr.in but after that I thing the guys are not working anymore in this issue ...

@suoto
Copy link
Author

suoto commented Jul 21, 2019

Unfortunately it seems this repo isn't being actively maintained, last PR merge was back in Nov 11, 2018.

@CollinChaffin
Copy link

I may be a bit naive about this, but is this just short of your requirements?

tmux-powerline-example

set -g status-interval 60
WEATHER='#(curl -s wttr.in/London:Stockholm:Moscow\?format\="%%l:+%%c%%20%%t%%60%%w&period=60")'
set -g status-right "$WEATHER ..."

@USA-RedDragon
Copy link

Correct @CollinChaffin. I've been using it locally for some time but it's not a good API. I actually forgot about this, I'll look into it more today

@USA-RedDragon
Copy link

As it turns out the GeoIP service it uses is also shut down: https://geoip.nekudo.com/shutdown

@gsusrafael
Copy link
Contributor

As it turns out the GeoIP service it uses is also shut down: https://geoip.nekudo.com/shutdown

@USA-RedDragon please check using ifconfig.co or api.ipapi.com

@PH111P
Copy link
Member

PH111P commented Sep 26, 2019

How's the status on this? If someone creates a PR, I'd be willing to merge it (conditioned on that it contains the necessary tests).

Further, I'd consider removing the old segment if it doesn't work anymore (and apparently will never work again, as I understand it).

@gsusrafael
Copy link
Contributor

gsusrafael commented Sep 26, 2019 via email

@baking-soda
Copy link

baking-soda commented Oct 8, 2019

Hi I just came to use powerline with tmux less than a week ago and absolutely love it. It was sad for me to find weather segment stops to work and the repostitory is not under active maintenance now. I did make an attempt last night, to modify segments.wthr to use wttr.in as suggested by this thread. The modifications are really simple, but they don't work (still no weather segment shows up). I don't have much experience with this code base, and don't even know how to debug it (couldn't find the log). Hence I am pasting the simple code here, hoping someone can help move this forward. Just because I really love this project. If you also love this project and has more experience of writing segment, please help me here:)

class WeatherSegment(KwThreadedSegment):
        interval = 600
        url_trunk = "wttr.in/"
        def __call__ (self, pl, update_first=True,
                location_query="Santa Clara,California",
                temp_coldest=30,
                temp_hottest=100,
                icons=None,
                **kwargs):
            self.location_query=location_query
            self.temp_coldest=temp_coldest
            self.temp_hottest=temp_hottest
            super(KwThreadedSegment, self).__call__(self, pl, update_first,
                location_query=location_query,
                temp_coldest=temp_coldest,
                temp_hottest=temp_hottest,
                icons=icons,
                    **kwargs)


        @staticmethod
        def key(**kwargs):
                return "default_query"


        def compute_state(self, default_query):
                url_loc = '+'.join(self.location_query.split())
                url = url_trunk + url_loc + '?' + 'u&format="%c:%t"'
                response = urllib_read(url.encode('utf-8'))
                if not response:
                        self.error('Failed to get response')
                        return None

                return response

        def render_one(self, query_response, icons=None, unit='C', temp_format=None, temp_coldest=-30, temp_hottest=40, **kwargs):
                if not query_response:
                        return None

                icon,temp_string=query_response.split(':')
                match = re.match(r'([+-]*\d+)', temp_string)
                if match.group(1) is None:
                    self.error('Fail to get temperature')
                    return None

                temp = int(match.group(1))

                if temp <= self.temp_coldest:
                        gradient_level = 0
                elif temp >= self.temp_hottest:
                        gradient_level = 100
                else:
                        gradient_level = (temp - self.temp_coldest) * 100.0 / (self.temp_hottest - self.temp_coldest)
                return [
                        {
                                'contents': icon + ' ',
                                'highlight_groups': ['weather'],
                                'divider_highlight_group': 'background:divider',
                        },
                        {
                                'contents': temp_string,
                                'highlight_groups': ['weather_temp_gradient', 'weather_temp', 'weather'],
                                'divider_highlight_group': 'background:divider',
                                'gradient_level': gradient_level,
                        },
                ]

@StopMotionCuber
Copy link
Contributor

I'm doing some efforts in porting the weather plugin to OpenWeatherMap.
Unfortunately an API key is required for that, however OpenWeatherMap states that it is supporting FOSS, will try if I get an API key with increased limits from there

@c0untzer0
Copy link

Any updates on this? Is a shame that this doesn't seem to be active. The segment is still broken. I've switched to other projects on most of my computers, but I still have some Linux using powerline which this would be nice on.

@StopMotionCuber
Copy link
Contributor

Well, my PR is still open

@PH111P
Copy link
Member

PH111P commented May 20, 2020

I did not take any action regarding that PR, because you, @StopMotionCuber, wrote “This is not really ready for merging yet”, so I assumed that the PR was/is still WIP.
Personally, I'm not against having segments where a user needs to provide credentials-like information in the config (in fact the IMAP segment works similarly); thus, I can imagine merging the PR once it is ready...

@rdelfin
Copy link

rdelfin commented May 25, 2020

Could we just get it merged and add some clarifying information in the documentation that an API key needs to be added? I get the concern about this being kind of hacky, but honestly this is better than the nothing we have right now. I'd be glad to help if there's anything missing you need help with @StopMotionCuber 😃

@StopMotionCuber
Copy link
Contributor

Oh, the only thing I'm missing on is time, but otherwise I can go on with this PR.
Will try to push that PR forward within the next few days, maybe already tonight.

@StopMotionCuber
Copy link
Contributor

Update on my PR:
I did some work now, and it's working on my machine (¯_(ツ)_/¯) however some tests are failing as they are based on stubbed urllib request answers which I have not yet replaced with the APIs that I'm using.
Also I introduced a (test)-breaking change, that the temperature gradient is calculated based on minimum and maximum value of your unit (before it was the unit that you would get from the request).

Otherwise I'm quite annoyed working on this issue with my new MacBook, as there seems to be some Ice Lake CPU Bug that is crashing PyCharm and/or macOS 😡

@PH111P
Copy link
Member

PH111P commented Sep 19, 2020

Fixed in #2038

@PH111P PH111P closed this as completed Sep 19, 2020
@PH111P PH111P linked a pull request Sep 19, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.