trying to fix wget bug
This commit is contained in:
parent
2653eb5bb2
commit
fe28173fa7
17
main.py
17
main.py
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import socket, os, time, select, urllib, sys, threading
|
import socket, os, time, select, urllib, sys, threading, subprocess
|
||||||
|
|
||||||
class Meshenger:
|
class Meshenger:
|
||||||
devices = {} #the dictionary of all the nodes this this node has seen
|
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:
|
if self.devices[device] > foreign_node_update:
|
||||||
print 'Foreign node"s index is newer, proceed to download index'
|
print 'Foreign node"s index is newer, proceed to download index'
|
||||||
self.get_index(device, nodepath)
|
status = self.get_index(device, nodepath)
|
||||||
|
if status:
|
||||||
print 'downloading messages'
|
print 'downloading messages'
|
||||||
self.get_messages(device, nodepath)
|
self.get_messages(device, nodepath)
|
||||||
self.node_timestamp(device)
|
self.node_timestamp(device)
|
||||||
|
else:
|
||||||
|
print 'wget failed'
|
||||||
|
|
||||||
time.sleep(5) #free process or ctrl+c
|
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.
|
Download the indices from other nodes.
|
||||||
"""
|
"""
|
||||||
time.sleep(0) # hack to prevent wget bug
|
# time.sleep(0) # hack to prevent wget bug
|
||||||
os.system('wget http://['+ip+'%adhoc0]:'+self.serve_port+'/index -O '+os.path.join(path,'index'))
|
# 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 ):
|
def get_messages(self, ip, path ):
|
||||||
"""
|
"""
|
||||||
|
@ -7,9 +7,11 @@
|
|||||||
|
|
||||||
-perhaps replace the functionality of self.devices with something based on crawling nodes/hash/
|
-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:
|
- HTTP calls the client needs:
|
||||||
- /msg/<uid> -> give list of all messages for this uid
|
- /msg/<uid> -> give list of all messages for this uid
|
||||||
- /msg/<uid>/<timestamp>.json -> get message for this timestamp
|
- /msg/<uid>/<timestamp> -> get message for this timestamp
|
||||||
- /clients -> return list of all known clients (uid's + usernames)
|
- /clients -> return list of all known clients (uid's + usernames)
|
||||||
- /getUID -> return uid for client ( based on what? mac? )
|
- /getUID -> return uid for client ( based on what? mac? )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user