def __calculate_parameters(self): """ Wylicza parametry dostawcy energi. """ current_time = self.client.get_current_time() # aktualny czas previous_time = self.client.get_previous_time() # czas 8h temu current_temperature = WheatherGenerator.get_temperature( current_time) # temperatura otoczenia previous_temperature = WheatherGenerator.get_temperature( previous_time) # temperatura otoczenia 8h temu water_temperature = EnergyProvider.get_water_temperature( previous_temperature) # temperatura wody parameters = (current_time, current_temperature, previous_temperature, water_temperature) return parameters
__author__ = "Rafał Prusak" __doc__ = "Skrypt zapisujący informację o pogodzie" import json from config import Configuration from wheather import WheatherGenerator from datetime import datetime, timedelta from dateutil import parser if __name__ == '__main__': result = {} Configuration.init() start_time = Configuration.get_start_time() time = parser.parse(start_time) time = time - timedelta(hours=8) i = 1 while i <= 10000: try: temperature = WheatherGenerator.get_temperature(time) result[str(time)] = temperature print(i, temperature, str(time)) time = time + timedelta(minutes=10) i += 1 except: print("koniec kluczy api!") break with open('data.txt', 'w') as outfile: json.dump(result, outfile)