Esempio n. 1
0
def main():
    loc = get_loc_from_ip()
    loc = json.loads(loc.text)

    # loc['latitude'], loc['longitude'] = (float(x) for x in loc['loc'].strip().split(','))
    # loc['time_zone'] = tzlocal.get_localzone().zone
    # print(loc['ip'])

    try:
        location = Location()
        location.name = loc['country']
        location.region = loc['country_iso']
        location.latitude = loc['latitude']
        location.longitude = loc['longitude']
        location.timezone = loc['time_zone']
    except ValueError as e:
        logger.error(str(e))
        return

    sunrise = location.sun()['sunrise'].replace(second=0) + timedelta(
        minutes=0)
    sunset = location.sun()['sunset'].replace(second=0) + timedelta(minutes=0)
    today = datetime.now().astimezone(
        pytz.timezone("Asia/Yerevan")) + timedelta(minutes=0)

    dawn = sunrise.astimezone(
        pytz.timezone("Asia/Yerevan")).strftime('%H:%M:%S')
    dusk = sunset.astimezone(
        pytz.timezone("Asia/Yerevan")).strftime('%H:%M:%S')
    now = today.strftime('%H:%M:%S')
    print(f'Dawn: {dawn}')
    print(f'Dusk: {dusk}')
    print(f'Now: {now}')
    print(
        f"You are in {location.name} and the timezone is {location.timezone}")

    if now < dawn:
        print("oh still dark")
        os.system(
            "gsettings set org.gnome.desktop.interface gtk-theme 'Mc-OS-CTLina-Gnome-Dark-1.3.2'"
        )
    elif dawn < now < dusk:
        print("it a brand new day")
        os.system(
            "gsettings set org.gnome.desktop.interface gtk-theme 'McOS-CTLina-Gnome-1.3.2'"
        )
    else:
        print("oh is dark")
        os.system(
            "gsettings set org.gnome.desktop.interface gtk-theme 'Mc-OS-CTLina-Gnome-Dark-1.3.2'"
        )

    return sunrise.astimezone(
        pytz.timezone("Asia/Yerevan")), sunset.astimezone(
            pytz.timezone("Asia/Yerevan"))
Esempio n. 2
0
#input files:
weather_irradiation = 'input/weather/solarirradiation_twenthe.csv'
weather_timebaseDataset = 3600  #in seconds per interval

#Simulation:
#number of days to simulate and skipping of initial days. Simulation starts at Sunday January 1.
numDays = 365  # number of days
startDay = 0  # Initial day

#Select the geographic location. Refer to the Astral plugin to see available locations (or give a lon+lat)
# Use e.g. https://www.latlong.net/

location = Location()
location.solar_depression = 'civil'
location.latitude = 52.239095
location.longitude = 6.857018
location.timezone = 'Europe/Amsterdam'
location.elevation = 0

#Select the devices in the neighbourhood

#Devices
#Scale overall consumption:
consumptionFactor = 1.0  #consumption was a bit too high

# Penetration of emerging technology in percentages
# all values must be between 0-100
# These indicate what percentage of the houses has a certain device

# Electric mobility, restriction that the sum <= 100
Esempio n. 3
0
 def test_SetLatitudeFloat(self):
     loc = Location()
     loc.latitude = 34.0
     assert loc.latitude == 34.0
Esempio n. 4
0
    def test_SetLatitudeString(self):
        loc = Location()
        loc.latitude = "24°28'N"

        assert loc.latitude == pytest.approx(24.46666666666666)
Esempio n. 5
0
    def test_LocationEquality_NotEqual(self, london_info):
        location1 = Location(london_info)
        location2 = Location(london_info)
        location2.latitude = 23.0

        assert location2 != location1