Are there some guidelines to follow in writing python code for embedded openwrt in the yun?
Like avoid the exceptions?
I have problem with.. the network (yet another..).
I have a simple arduino code that at a certain point calls via Bridge Process::run a python script. The python script is calling an ip with urllib2 via http get and return it to the Bridge. The http response could be a message error or a number.
I don't know if this is the problem, but if in the python script I have a nested exception handling.. it caused the openwrt to lost the network (and I need to reboot it)
this is an example of the python code:
req = urllib2.Request(ip) try: response = urllib2.urlopen(req, timeout=5) t = the_page = response.read() try: t = int(t) foo() # and go on except Exception as e: print 'no number' print e except Exception as e: print 'url lib error' print e
after the first negative response (the 'no number') the following Bridge call ends up with a: urlopen error host is unreachable and I don't manage anymore to ssh into the yun (but it works good because the bridge it is giving me this error, just no network, no ping)
I tried to tail -f /vat/bridge error log but after the first exception.. I have no more the yun in my network, also the ping says host is down.
This story makes me think that something is wrong with the nested exception and it is a construct to be avoided and so the first question.
any kind of advice?