properly commented savepoint
This commit is contained in:
parent
66cd549021
commit
50a52e447b
13
main.py
13
main.py
@ -49,7 +49,7 @@ class Meshenger:
|
|||||||
while True:
|
while True:
|
||||||
|
|
||||||
if len(self.devices) > 0:
|
if len(self.devices) > 0:
|
||||||
print 'found', len(self.devices),'device(s) retreiving indices'
|
print 'found', len(self.devices),'device(s)'
|
||||||
|
|
||||||
for device in self.devices:
|
for device in self.devices:
|
||||||
nodepath = self.ip_to_hash(device) #make a folder for the node (nodes/'hash'/)
|
nodepath = self.ip_to_hash(device) #make a folder for the node (nodes/'hash'/)
|
||||||
@ -57,9 +57,9 @@ class Meshenger:
|
|||||||
|
|
||||||
|
|
||||||
print 'Checking age of foreign node index'
|
print 'Checking age of foreign node index'
|
||||||
print self.devices[device]
|
print self.devices[device], 'Foreign announce timestamp'
|
||||||
foreign_node_update = open(nodeupdatepath).read()
|
foreign_node_update = open(nodeupdatepath).read()
|
||||||
print foreign_node_update
|
print foreign_node_update, 'Locally stored timestamp for device'
|
||||||
|
|
||||||
|
|
||||||
if self.devices[device] > foreign_node_update:
|
if self.devices[device] > foreign_node_update:
|
||||||
@ -69,9 +69,6 @@ class Meshenger:
|
|||||||
print 'downloading messages'
|
print 'downloading messages'
|
||||||
self.get_messages(device, nodepath)
|
self.get_messages(device, nodepath)
|
||||||
|
|
||||||
#print 'updating own index'
|
|
||||||
#self.build_index()
|
|
||||||
|
|
||||||
time.sleep(5) #free process or ctrl+c
|
time.sleep(5) #free process or ctrl+c
|
||||||
|
|
||||||
def node_timestamp(self, ip):
|
def node_timestamp(self, ip):
|
||||||
@ -109,15 +106,15 @@ Discover other devices by listening to the Meshenger announce port
|
|||||||
result = select.select([s],[],[])[0][0].recvfrom(bufferSize)
|
result = select.select([s],[],[])[0][0].recvfrom(bufferSize)
|
||||||
|
|
||||||
if result[1][0] in self.devices and result[1][0] != self.own_ip:
|
if result[1][0] in self.devices and result[1][0] != self.own_ip:
|
||||||
print 'node al een keer gezien'
|
print 'Known node', result[1][0]
|
||||||
self.devices[result[1][0]] = result[0]
|
self.devices[result[1][0]] = result[0]
|
||||||
#self.devices.append(result[1][0])
|
#self.devices.append(result[1][0])
|
||||||
|
|
||||||
elif result[1][0] not in self.devices and result[1][0] != self.own_ip:
|
elif result[1][0] not in self.devices and result[1][0] != self.own_ip:
|
||||||
print 'node eerste keer'
|
|
||||||
#loop for first time
|
#loop for first time
|
||||||
self.devices[result[1][0]] = result[0]
|
self.devices[result[1][0]] = result[0]
|
||||||
self.node_timestamp(result[1][0])
|
self.node_timestamp(result[1][0])
|
||||||
|
print 'New node', result[1][0]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user