From fe28173fa7f4340c9134b07517824e031e95b860 Mon Sep 17 00:00:00 2001 From: jngrt Date: Fri, 23 May 2014 18:45:45 +0200 Subject: [PATCH] trying to fix wget bug --- main.py | 23 +++++++++++++++-------- meshenger_roadmap | 4 +++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 5d27bec..188607d 100755 --- a/main.py +++ b/main.py @@ -1,6 +1,6 @@ #!/usr/bin/python -import socket, os, time, select, urllib, sys, threading +import socket, os, time, select, urllib, sys, threading, subprocess class Meshenger: devices = {} #the dictionary of all the nodes this this node has seen @@ -76,10 +76,13 @@ class Meshenger: if self.devices[device] > foreign_node_update: print 'Foreign node"s index is newer, proceed to download index' - self.get_index(device, nodepath) - print 'downloading messages' - self.get_messages(device, nodepath) - self.node_timestamp(device) + status = self.get_index(device, nodepath) + if status: + print 'downloading messages' + self.get_messages(device, nodepath) + self.node_timestamp(device) + else: + print 'wget failed' time.sleep(5) #free process or ctrl+c @@ -225,9 +228,13 @@ Save the time of the last update. """ Download the indices from other nodes. """ - time.sleep(0) # hack to prevent wget bug - os.system('wget http://['+ip+'%adhoc0]:'+self.serve_port+'/index -O '+os.path.join(path,'index')) - + # time.sleep(0) # hack to prevent wget bug + # os.system('wget http://['+ip+'%adhoc0]:'+self.serve_port+'/index -O '+os.path.join(path,'index')) + command = 'wget http://['+ip+'%adhoc0]:'+self.serve_port+'/index -O '+os.path.join(path,'index') + print 'get_index: ', command + status = subprocess.call( command, shell=True ) + print 'get_index wget status: ', status + return status == 0 def get_messages(self, ip, path ): """ diff --git a/meshenger_roadmap b/meshenger_roadmap index d45fc35..ea7ffbf 100644 --- a/meshenger_roadmap +++ b/meshenger_roadmap @@ -7,9 +7,11 @@ -perhaps replace the functionality of self.devices with something based on crawling nodes/hash/ +-sometimes node tries to connect to itself (something wrong with receiving broadcast maybe??) + - HTTP calls the client needs: - /msg/ -> give list of all messages for this uid -- /msg//.json -> get message for this timestamp +- /msg// -> get message for this timestamp - /clients -> return list of all known clients (uid's + usernames) - /getUID -> return uid for client ( based on what? mac? )