<commit_before># weather.py
# Author: <NAME>
# Author: <NAME>
# Version: May 25, 2016

import json
import urllib

from bottle import template

from modules.module import Module

# Global configuration variables
WEATHER_API_URL = 'http://www.prevision-meteo.ch/services/json/bruxelles-20'

class Weather(Module):
    '''Class representing a module that shows current weather and forecasts.'''
    def __init__(self):
        super().__init__('Weather', 3600)
    
    def widget(self):
        def render():
            try:
                with urllib.request.urlopen(WEATHER_API_URL) as response:
                    data = json.loads(response.read().decode('utf-8'))
                    return template('./modules/weather/widget.tpl', weather=data)
            except Exception as e:
                print('Erreur:', e)
                return 'Error'
        return render
    
    def page(self):
        return None<commit_msg>Modules: Add message error when weather info not available<commit_after># weather.py
# Author: <NAME>
# Author: <NAME>
# Version: May 26, 2016

import json
import urllib

from bottle import template

from modules.module import Module

# Global configuration variables
WEATHER_API_URL = 'http://www.prevision-meteo.ch/services/json/bruxelles-20'

class Weather(Module):
    '''Class representing a module that shows current weather and forecasts.'''
    def __init__(self):
        super().__init__('Weather', 3600)
    
    def widget(self):
        def render():
            try:
                with urllib.request.urlopen(WEATHER_API_URL) as response:
                    data = json.loads(response.read().decode('utf-8'))
                    return template('./modules/weather/widget.tpl', weather=data)
            except:
                return '<div id="weather" class="widget">Weather info not available at this time.</div>'
        return render
    
    def page(self):
        return None
{'fraction_non_alphanumeric': 0.10725388601036269, 'fraction_numerical': 0.013471502590673576, 'mean_word_length': 2.5237226277372264, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4893955', 'n_tokens_mistral': 564, 'n_tokens_neox': 532, 'n_words': 152}