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
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
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
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