-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,5 @@ beautifulsoup4==4.11.1 | |
wget==3.2 | ||
cairosvg>=0.7.0 | ||
Pillow==9.1.0 | ||
# | ||
# Geo location | ||
geocoder>=1.38.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
# https://stackoverflow.com/a/11236372 | ||
# apt install gfortran libffi-dev | ||
# pip3 install pvlib ephem pytz beautifulsoup4 cairosvg wget requests Pillow | ||
|
||
|
||
import os | ||
from pytz import timezone | ||
import sunrise_lib | ||
|
||
import geocoder | ||
|
||
def get_lat_lon(): | ||
return geocoder.ip('me') | ||
|
||
def main(): | ||
test() | ||
path_local = sunrise_lib.get_config_path('geo') | ||
config_geo = sunrise_lib.config_geo | ||
print("Config city:", config_geo.geo.city) | ||
print("Config lat:", config_geo.geo.lat) | ||
print("Config lon:", config_geo.geo.lon) | ||
|
||
print() | ||
g = get_lat_lon() | ||
city = g.city.lower() | ||
print("Detected city:", city) | ||
print("Detected lat/lon:", g.latlng) | ||
#print("Detected country:", g.country) | ||
|
||
if config_geo.geo.city != city: | ||
print("Please update city") | ||
if config_geo.geo.lat != g.latlng[0]: | ||
print("Please update lat") | ||
if config_geo.geo.lon != g.latlng[1]: | ||
print("Please update lon") | ||
|
||
print("Your config file is stored at:") | ||
print(path_local) | ||
|
||
def test(): | ||
g = get_lat_lon() | ||
assert len(g.latlng) == 2 | ||
assert g.latlng[0] != 0 | ||
assert g.latlng[1] != 0 | ||
print("Detected lat/lon:", get_lat_lon().latlng) | ||
#print("City:", g.city) | ||
#run_main(elev, show_plots) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh -e | ||
|
||
src/geolocation.py | ||
|