HackerShackOfficial / Smart-Mirror

Raspberry powered mirror which can display news, weather, calendar events
MIT License
907 stars 384 forks source link

Invalid Syntax #107

Open izzybella49 opened 6 years ago

izzybella49 commented 6 years ago

My Smart Mirror gave me this message when I tried to run it: pi@raspberrypi:~/Smart-Mirror $ python smartmirror.py File "smartmirror.py", line 130 except Exception as e:

SyntaxError: invalid syntax

Thanks in advance

izzybella49 commented 6 years ago

def get_ip(self): try: ip_url = "https://ipstack.com" req = requests.get(ip_url) ip_json = json.loads(req.text) return ip_json['75.148.185.113'] except Exception as e:

               traceback.print_exc(e)
        return "Error: %s. Cannot get ip." % e

This is the code can someone please spot something wrong with my code.

big1surg commented 6 years ago

def get_ip(self): try: ip_url = "http://jsonip.com/" req = requests.get(ip_url) ip_json = json.loads(req.text) return ip_json['ip'] except Exception as e: traceback.print_exc() return "Error: %s. Cannot get ip." % e

dangercrow commented 5 years ago

https://docs.python.org/2/tutorial/errors.html

Sounds like you're using python 3 syntax on python 2 code.

As the above link says, it's catch Exception, e: in old python