From fb023f8a8bc1ac9ace48623fb66b95d0972210ae Mon Sep 17 00:00:00 2001 From: Roel Date: Thu, 24 Apr 2014 12:09:53 +0200 Subject: [PATCH] added exception to main if foreing index cant be downloaded --- lazyinstall/lazyinstall2.sh | 2 +- main.py | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lazyinstall/lazyinstall2.sh b/lazyinstall/lazyinstall2.sh index 2c647e7..413dfe5 100644 --- a/lazyinstall/lazyinstall2.sh +++ b/lazyinstall/lazyinstall2.sh @@ -28,7 +28,7 @@ git clone git://github.com/jngrt/meshenger.git mv uhttpd /etc/config/uhttpd -echo 'my ip address is:' +echo 'my ip address is:' #klopt nog niet ifconfig br-lan | grep 'inet addr' echo 'Done configuring you can now reboot using $reboot -f' diff --git a/main.py b/main.py index 375cae3..3b0d8bd 100755 --- a/main.py +++ b/main.py @@ -14,7 +14,7 @@ class Meshenger: def __init__(self): - #os.system("echo 1 >> /proc/sys/net/ipv6/conf/br-lan/disable_ipv6") + os.system("echo 1 >> /proc/sys/net/ipv6/conf/br-lan/disable_ipv6") self.own_ip = self.get_ip_adress() if not os.path.exists(self.msg_dir): @@ -144,15 +144,16 @@ class Meshenger: """ Get new messages from other node based on it's index file """ - - with open(os.path.join(path,'index')) as index: - index = index.read().split('\n') - for message in index: - messagepath = os.path.join(os.path.abspath(self.msg_dir), message) - if not os.path.exists(messagepath): - print 'downloading', message, 'to', messagepath - os.system('wget http://['+ip+'%adhoc0]:13338/msg/'+message+' -O '+messagepath) - + try: + with open(os.path.join(path,'index')) as index: + index = index.read().split('\n') + for message in index: + messagepath = os.path.join(os.path.abspath(self.msg_dir), message) + if not os.path.exists(messagepath): + print 'downloading', message, 'to', messagepath + os.system('wget http://['+ip+'%adhoc0]:13338/msg/'+message+' -O '+messagepath) + except: + pass def ip_to_hash(self, ip): """ @@ -178,7 +179,7 @@ class Meshenger: Hack to adhoc0's inet6 adress """ if not os.path.isfile('interfaceip6adress'): - os.system('ifconfig -a adhoc0 | grep inet6 > interfaceip6adress') + os.system('ifconfig -a adhoc0 | grep inet6 > /root/meshenger/interfaceip6adress') with open('interfaceip6adress', 'r') as a: return a.read().split()[2].split('/')[0]