changing path for received msgs

This commit is contained in:
jngrt 2014-05-23 18:56:45 +02:00
parent fe28173fa7
commit d6549ea19d

24
main.py
View File

@ -77,12 +77,17 @@ 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'
status = self.get_index(device, nodepath) status = self.get_index(device, nodepath)
if status: if not status:
print 'downloading messages' print 'index wget failed'
self.get_messages(device, nodepath) continue
self.node_timestamp(device)
else: print 'downloading messages'
print 'wget failed' status = self.get_messages(device, nodepath)
if not status:
print 'getting messages failed'
continue
self.node_timestamp(device)
time.sleep(5) #free process or ctrl+c time.sleep(5) #free process or ctrl+c
@ -247,13 +252,14 @@ Get new messages from other node based on it's index file
index = index.read().split('\n') index = index.read().split('\n')
for message in index: for message in index:
# messagepath = os.path.join(os.path.abspath(self.msg_dir), message) # messagepath = os.path.join(os.path.abspath(self.msg_dir), message)
messagepath = os.path.join( self.msg_dir, message ) messagepath = os.path.relpath( message )
if not os.path.exists(messagepath): if not os.path.exists(messagepath):
print 'downloading', message, 'to', messagepath print 'downloading', message, 'to', messagepath
os.system('wget http://['+ip+'%adhoc0]:' + self.serve_port + '/' + message+' -O ' + messagepath) status = subprocess.call('wget http://['+ip+'%adhoc0]:' + self.serve_port + '/' + message+' -O ' + messagepath, shell=True)
return status == 0
except: except:
print 'Failed to download messages' print 'Failed to download messages'
pass return False
def ip_to_hash_path(self, ip): def ip_to_hash_path(self, ip):
""" """