Пример #1
0
def send_data():
    """Send data to the website with openweather data."""
    try:
        token = get_token()
        req = setup_request()
        while True:
            data = get_data()
            if data:
                header = {"Authorization": f"Token {token}"}
                temp = data.get("temp")
                timestamp = utcisoformat(datetime.now())
                print(f"Sending data {temp} at {timestamp}")
                data = {
                    "sensor_type": "T",
                    "device": "Raspberry",
                    "measure": temp,
                    "timestamp": timestamp,
                    "name": "BMP280",
                }
                response = req.post("http://www.simteiva.fr/api/v1/",
                                    headers=header,
                                    data=data)
            time.sleep(10)
    except KeyboardInterrupt:
        logger.warning("Interrupted script execution with keyboard")
        sys.exit()
Пример #2
0
def text_reply(msg):
    text = msg.text
    if text.find('电影') > -1:
        return '好看的电影呢'
    elif text.find('傻') > -1:
        return '你很聪明么?'
    elif text.find('天气') > -1:
        return weather.get_data('北京')
    elif text.find('在吗') > -1:
        return say_notice()
    return msg.text
Пример #3
0
	def test_local(self):
		result = get_data("22031") # Fairfax
		assert (("Sunny" in result["weather"]) or ("Fair" in result["weather"]) or ("Windy" in result["weather"]) or ("Rainy" in result["weather"]) or ("Snowy" in result["weather"]) or ("Cloudy" in result["weather"]))
Пример #4
0
	def test_westcoast(self):
		result = get_mood(get_data("90001")) # Los Angeles
		assert result["mood"] in mood_types
Пример #5
0
	def test_midwest(self):
		result = get_mood(get_data("60007")) # Chicago
		assert result["mood"] in mood_types
Пример #6
0
	def test_local(self):
		result = get_mood(get_data("22031")) # Fairfax
		assert result["mood"] in mood_types
Пример #7
0
	def test_westcoast(self):
		result = get_data("90001") # Los Angeles
		assert (("Sunny" in result["weather"]) or ("Fair" in result["weather"]) or ("Windy" in result["weather"]) or ("Rainy" in result["weather"]) or ("Snowy" in result["weather"]) or ("Cloudy" in result["weather"]))
Пример #8
0
	def test_midwest(self):
		result = get_data("60007") # Chicago
		assert (("Sunny" in result["weather"]) or ("Fair" in result["weather"]) or ("Windy" in result["weather"]) or ("Rainy" in result["weather"]) or ("Snowy" in result["weather"]) or ("Cloudy" in result["weather"]))