示例#1
0
    def parse_alert(alert):
        data = {
            'description': alert['description'],
            'expires': datetime.fromtimestamp(int(alert['expires_epoch'])),
        }

        if 'level_meteoalarm' not in alert:
            # only generate URIs for US alerts
            try:
                zone = alert['ZONES'][0]
                data['uri'] = '{}/US/{}/{}.html'.format(
                    SERVICES['wund']['url'], zone['state'], zone['ZONE'])
            except:
                location = '{},{}'.format(settings['location']['latitude'],
                                          settings['location']['longitude'])
                data['uri'] = wunderground.get_forecast_url(location)
        return data
示例#2
0
    def parse_alert(alert):
        data = {
            'description': alert['description'],
            'expires': datetime.fromtimestamp(int(alert['expires_epoch'])),
        }

        if 'level_meteoalarm' not in alert:
            # only generate URIs for US alerts
            try:
                zone = alert['ZONES'][0]
                data['uri'] = '{}/US/{}/{}.html'.format(SERVICES['wund']['url'],
                                                        zone['state'],
                                                        zone['ZONE'])
            except:
                location = '{},{}'.format(settings['location']['latitude'],
                                          settings['location']['longitude'])
                data['uri'] = wunderground.get_forecast_url(location)
        return data
示例#3
0
        def parse_alert(alert):
            data = { 'description': alert['description'] }
            try:
                data['expires'] = datetime.fromtimestamp(int(alert['expires_epoch']))
            except ValueError:
                data['expires'] = None
                LOG.warn('invalid expiration time: %s', alert['expires_epoch'])

            if 'level_meteoalarm' not in alert:
                # only generate URIs for US alerts
                try:
                    zone = alert['ZONES'][0]
                    data['uri'] = '{}/US/{}/{}.html'.format(
                        SERVICES['wund']['url'], zone['state'], zone['ZONE'])
                except:
                    location = '{},{}'.format(self.config['location']['latitude'],
                                              self.config['location']['longitude'])
                    data['uri'] = wunderground.get_forecast_url(location)
            return data
示例#4
0
        def parse_alert(alert):
            data = {'description': alert['description']}
            try:
                data['expires'] = datetime.fromtimestamp(
                    int(alert['expires_epoch']))
            except ValueError:
                data['expires'] = None
                LOG.warn('invalid expiration time: %s', alert['expires_epoch'])

            if 'level_meteoalarm' not in alert:
                # only generate URIs for US alerts
                try:
                    zone = alert['ZONES'][0]
                    data['uri'] = '{}/US/{}/{}.html'.format(
                        SERVICES['wund']['url'], zone['state'], zone['ZONE'])
                except:
                    location = '{},{}'.format(
                        self.config['location']['latitude'],
                        self.config['location']['longitude'])
                    data['uri'] = wunderground.get_forecast_url(location)
            return data