Last active
December 11, 2015 16:44
-
-
Save miawgogo/4d9117a9f12a8ad37af4 to your computer and use it in GitHub Desktop.
code and error
This file contains hidden or 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
def getsunrise(lat="", lng="", formatted=1): | |
if lat=="" or lng == "": | |
print "Developer failed to Get lat and long to libary, atempting libary devloper method, uses the internet" | |
api=urllib2.urlopen("http://freegeoip.net/json/") | |
lat=str(json.loads(api.read().decode("UTF-8"))["latitude"]) | |
print lat | |
lng=str(json.loads(api.read().decode("UTF-8"))["longitude"]) | |
sunapi=urllib2.urlopen("http://api.sunrise-sunset.org/json?lat=" + lat + "&lng=" + lng + "&formatted=" + formatted) | |
return json.loads(sunapi.read().decode("UTF-8"))['results']['sunrise'] | |
#Traceback (most recent call last): | |
# File "Suntimes.py", line 32, in <module> | |
# if nighttrue() == True: | |
# File "Suntimes.py", line 25, in nighttrue | |
# sunrise = time.strptime(getsunrise(lat, lng, 1), "%Y-%m-%dT%H:%M:%S") | |
# File "Suntimes.py", line 11, in getsunrise | |
# lng=str(json.loads(api.read().decode("UTF-8"))["longitude"]) | |
# File "/usr/lib/python2.7/json/__init__.py", line 338, in loads | |
# return _default_decoder.decode(s) | |
# File "/usr/lib/python2.7/json/decoder.py", line 366, in decode | |
# obj, end = self.raw_decode(s, idx=_w(s, 0).end()) | |
# File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode | |
# raise ValueError("No JSON object could be decoded") | |
#ValueError: No JSON object could be decoded | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment