main.py fixed, working with sending messages for users, in subfoldes

This commit is contained in:
jngrt 2014-05-23 19:47:04 +02:00
parent 60d77071c5
commit 0e587e93d7
2 changed files with 5 additions and 6 deletions

View File

@ -237,7 +237,6 @@ Download the indices from other nodes.
command = '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 print 'get_index: ', command
status = subprocess.call( command, shell=True ) status = subprocess.call( command, shell=True )
print 'get_index wget status: ', status
return status == 0 return status == 0
def get_messages(self, ip, path ): def get_messages(self, ip, path ):
@ -250,7 +249,6 @@ Get new messages from other node based on it's index file
with open(os.path.join(path,'index')) as index: with open(os.path.join(path,'index')) as index:
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)
parts = message.split('/') parts = message.split('/')
dirpath = os.path.join( parts[0], parts[1]) dirpath = os.path.join( parts[0], parts[1])
if not os.path.isdir( dirpath ): if not os.path.isdir( dirpath ):
@ -260,10 +258,11 @@ Get new messages from other node based on it's index file
if not os.path.exists(messagepath): if not os.path.exists(messagepath):
print 'downloading', message, 'to', messagepath print 'downloading', message, 'to', messagepath
command = 'wget http://['+ip+'%adhoc0]:' + self.serve_port + '/' + message+' -O ' + messagepath command = 'wget http://['+ip+'%adhoc0]:' + self.serve_port + '/' + message+' -O ' + messagepath
print command
status = subprocess.call( command, shell=True) status = subprocess.call( command, shell=True)
print 'get_messages wget status: ', status if status != 0:
return status == 0 return False
# succesfuly downloaded all messages, return true
return True
except: except:
print 'Failed to download messages' print 'Failed to download messages'
return False return False

View File

@ -13,7 +13,7 @@
- /msg/<uid> -> give list of all messages for this uid - /msg/<uid> -> give list of all messages for this uid
- /msg/<uid>/<timestamp> -> 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 ( unique id based on what? mac address? )
# Cryptoshit # Cryptoshit