From ce125c354efbe7b6fb2df0c788d37d7178c56732 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 19 Oct 2020 16:23:18 +0100 Subject: [PATCH] Cleaning up --- .vscode/settings.json | 6 ------ email_playground.py | 16 ---------------- playground.py | 39 --------------------------------------- sample_response.json | 42 ------------------------------------------ sleep.py | 7 ------- 5 files changed, 110 deletions(-) delete mode 100644 .vscode/settings.json delete mode 100644 email_playground.py delete mode 100644 playground.py delete mode 100644 sample_response.json delete mode 100755 sleep.py diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 89e1616..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "python.pythonPath": "/Users/max/Desktop/ICL-IoT-Weather/venv/bin/python3.7", - "python.linting.pylintEnabled": false, - "python.linting.flake8Enabled": true, - "python.linting.enabled": true -} \ No newline at end of file diff --git a/email_playground.py b/email_playground.py deleted file mode 100644 index e2f083f..0000000 --- a/email_playground.py +++ /dev/null @@ -1,16 +0,0 @@ -import smtplib -import ssl - -port = 465 # For SSL -smtp_server = "smtp.gmail.com" -sender_email = "iotdemax@gmail.com" # Enter your address -receiver_email = "mh2817@ic.ac.uk" # Enter receiver address -__PASSWORD_PATH = "secrets/email_password.txt" -with open(__PASSWORD_PATH, "r") as password_file: - password = password_file.read() -message = "Testing email..." - -context = ssl.create_default_context() -with smtplib.SMTP_SSL(smtp_server, port, context=context) as server: - server.login(sender_email, password) - server.sendmail(sender_email, receiver_email, message) diff --git a/playground.py b/playground.py deleted file mode 100644 index baa6001..0000000 --- a/playground.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/local/bin/python -from firebase_admin import credentials, firestore, initialize_app -from requests import get as api_get -from time import time as timestamp -from datetime import datetime - -cert_path = "secrets/icl-iot-weather-firebase-adminsdk-d2a8f-577125a0ff.json" -cred = credentials.Certificate(cert_path) -initialize_app(cred) - -firestore_db = firestore.client() - -with open("secrets/weather_api_key.txt", "r") as api_key_file: - api_key = api_key_file.read() - -request_endpoint = "api.openweathermap.org/data/2.5/weather" -request_city = "London" - -request_url = f"https://{str(request_endpoint)}?q={str(request_city)}&appid={str(api_key)}".split('\n')[0] - -api_rsp = api_get(request_url) -print(api_rsp.text) - -current_weather_data = { - timestamp": timestamp.now(), - "datetime": datetime.now(), - "temp": current_temp_celcius, - "humidity": current_humidity_pct, - "cloud": current_cloud_pct, - "wind": current_wind_ms, - "rain_1h": rain_mm_1h, - "is_test": is_test" -} - -snapshots = list(firestore_db.collection(u'weather_data').get()) -for snapshot in snapshots: - print(snapshot.to_dict()) - -#firestore_db.collection(u'songs').add({'song': 'Imagine', 'artist': 'John Lennon'} diff --git a/sample_response.json b/sample_response.json deleted file mode 100644 index 5b73728..0000000 --- a/sample_response.json +++ /dev/null @@ -1,42 +0,0 @@ -test({ - "coord": { - "lon": -0.13, - "lat": 51.51 - }, - "weather": [ - { - "id": 741, - "main": "Fog", - "description": "fog", - "icon": "50n" - } - ], - "base": "stations", - "main": { - "temp": 284.04, - "pressure": 1011, - "humidity": 93, - "tempmin": 280.93, - "tempmax": 287.04 - }, - "visibility": 10000, - "wind": { - "speed": 1.5 - }, - "clouds": { - "all": 20 - }, - "dt": 1570234102, - "sys": { - "type": 1, - "id": 1417, - "message": 0.0102, - "country": "GB", - "sunrise": 1570255614, - "sunset": 1570296659 - }, - "timezone": 3600, - "id": 2643743, - "name": "London", - "cod": 200 -}) diff --git a/sleep.py b/sleep.py deleted file mode 100755 index 9e2599a..0000000 --- a/sleep.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/local/bin/python -import time -import logging -logging.warning('RUNNING.>.>.') -while True: - logging.info('Running...') - time.sleep(5)