Fixed pathing to graphics issue

This commit is contained in:
mrwunderbar666 2017-07-31 10:06:08 +08:00
parent 95efe4d2c1
commit 9bd47e7ad1

View File

@ -14,14 +14,18 @@
from __future__ import print_function from __future__ import print_function
from datetime import date
from datetime import datetime from datetime import datetime
import calendar import calendar
import urllib, json import urllib, json
import time import time
import os
from escpos.printer import Usb from escpos.printer import Usb
""" Setting up the main pathing """
this_dir, this_filename = os.path.split(__file__)
GRAPHICS_PATH = os.path.join(this_dir, "graphics/climacons/")
# Adapt to your needs # Adapt to your needs
printer = Usb(0x0416, 0x5011, profile="POS-5890") printer = Usb(0x0416, 0x5011, profile="POS-5890")
@ -34,7 +38,7 @@ LONG = "114.189945" # Your Location
def forecast_icon(idx): def forecast_icon(idx):
icon = data['daily']['data'][idx]['icon'] icon = data['daily']['data'][idx]['icon']
image = "/graphics/climacons/" + icon + ".png" image = GRAPHICS_PATH + icon + ".png"
return image return image
@ -68,7 +72,7 @@ def forecast(idx):
def icon(): def icon():
icon = data['currently']['icon'] icon = data['currently']['icon']
image = "/graphics/" + icon + ".png" image = GRAPHICS_PATH + icon + ".png"
return image return image