Cleaning up

This commit is contained in:
Max 2020-10-19 16:23:18 +01:00
parent 9c76e06008
commit ce125c354e
5 changed files with 0 additions and 110 deletions

View File

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

View File

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

View File

@ -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'}

View File

@ -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
})

View File

@ -1,7 +0,0 @@
#!/usr/local/bin/python
import time
import logging
logging.warning('RUNNING.>.>.')
while True:
logging.info('Running...')
time.sleep(5)