Skip to content

Commit

Permalink
improved execution handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aceisace authored Jan 18, 2020
1 parent 566cd03 commit 0a87044
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions modules/inkycal_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
"""
from __future__ import print_function
import pyowm
from settings import *
from configuration import *
from PIL import Image, ImageDraw, ImageFont
import arrow
import math, decimal
dec = decimal.Decimal

Expand Down Expand Up @@ -130,7 +127,7 @@ def to_units(kelvin):
return conversion

def red_temp(negative_temperature):
if display_type == 'colour' and negative_temperature[0] == '-' and units == 'metric':
if three_colour_support == True and negative_temperature[0] == '-' and units == 'metric':
colour = 'red'
else:
colour = 'black'
Expand Down Expand Up @@ -160,9 +157,9 @@ def to_hours(datetime_object, simple = False):
fontsize += 1
font = ImageFont.truetype(NotoSans+'.ttf', fontsize)

def main():
def generate_image():
"""Connect to Openweathermap API and fetch weather data"""
if top_section == "Weather" and api_key != "" and owm.is_API_online() is True:
if top_section == "inkycal_weather" and api_key != "" and owm.is_API_online() is True:
try:
clear_image('top_section')
print('Weather module: Connectivity check passed, Generating image...',
Expand Down Expand Up @@ -331,10 +328,10 @@ def get_moon_phase():
draw.line((coloumn7, line_start_y, coloumn7, line_end_y), fill='black')
draw.line((0, top_section_height-border_top, top_section_width-
border_left, top_section_height-border_top),
fill='red' if display_type == 'colour' else 'black' , width=3)
fill='red' if three_colour_support == 'True' else 'black' , width=3)

weather_image = crop_image(image, 'top_section')
weather_image.save(image_path+'weather.png')
weather_image.save(image_path+'inkycal_weather.png')
print('Done')

except Exception as e:
Expand All @@ -348,8 +345,10 @@ def get_moon_phase():
write_text(coloumn_width*6, row_height, message, humidity_icon_now_pos,
font = font)
weather_image = crop_image(image, 'top_section')
weather_image.save(image_path+'weather.png')
weather_image.save(image_path+'inkycal_weather.png')
pass

if __name__ == '__main__':
main()
def main():
generate_image()

main()

0 comments on commit 0a87044

Please sign in to comment.