Last active
December 20, 2015 17:28
-
-
Save stucka/6168508 to your computer and use it in GitHub Desktop.
Run some code an hour before sunrise.
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
#!/home/mstucka/bin/python | |
#Want to do something an hour before sunrise? | |
#sleep `./hourtosunrise.py` | |
#./dosomething.sh | |
import ephem | |
import datetime | |
import sys | |
now=datetime.datetime.now() | |
Macon=ephem.Observer() | |
Macon.lat="32.841" | |
Macon.long="-83.632" | |
Macon.elevation=116 #meters | |
sun=ephem.Sun() | |
sunrise=ephem.localtime(Macon.next_rising(sun)) | |
timetosunrise=(sunrise-now).seconds | |
sys.stdout.write(str(timetosunrise-3600)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment