Пример #1
0
""" Get local weather data from the DarkSky API """

import requests
from os import path
from scripts.py.application import logger
import random
import json

appPath = path.dirname(path.abspath(__file__))

name = 'Forecast-Weather'
log = logger.setup_logger(name)

iconDir = path.abspath(path.dirname(__file__) + '/media/icons/weather_conditions/static')
log.debug('Found weather icon dir: %s' % iconDir)
mediaDir = path.abspath(appPath + '/media')
imagesDir = path.abspath(mediaDir + '/images')

darkSkyURL = 'https://api.darksky.net/forecast/'
log.info('Weather data provided by Forecast.io')

def conn_image(status):
    global imagesDir, mediaDir
    if status:
        return imagesDir + '/light_on.png'
    else:
        return imagesDir + '/light_off.png'


def get_compass(num):
    val = int((int(num) / 22.5) + .5)
Пример #2
0
import PySimpleGUI as sg
import os.path as path
import sys

sys.path.append(path.abspath('.'))
from scripts.py.application.logger import setup_logger
from scripts.py.forecast.IPtoGP import getByIP
from scripts.py.forecast.weather import check_key
from scripts.py.forecast.weather import getWeather
from scripts.py.forecast.weather import getIcon
from scripts.py.forecast.weather import get_compass
from scripts.py.forecast.weather import conn_image

name = 'Forecast'

log = setup_logger(name)
log.info('The logger is awake')

from scripts.py.application import conf

log.debug('Determining where in the filesystem I am')
new_key = False

appPath = path.dirname(path.abspath(__file__))
log.debug(' Found path: %s' % appPath)

confPath = path.abspath(appPath + '/forecast/conf')

existingConfFilepath = path.abspath(confPath + '/forecast_conf.json')

if path.exists(confPath + '/forecast_conf.json'):