diff --git a/src/morevna.py b/src/morevna.py --- a/src/morevna.py +++ b/src/morevna.py @@ -3,7 +3,7 @@ import os.path import logging as log from argparse import ArgumentParser -from util import spawnDaemon +from util import spawnDaemon, splitHost import config as conf import stats from hashtree import HashTree @@ -33,26 +33,27 @@ def push(args): _checkFile(args.datafile) if args.tree: _checkFile(args.tree) - if args.host: conf.hosts.insert(0,args.host) + if args.host: conf.hosts=[args.host] if args.port: conf.port=args.port c=Client(args.datafile,args.tree) - with ClientConnection() as con: - c.setConnection(con) - blocksToTransfer=c.negotiate() - c.sendData(blocksToTransfer) - print() - print(stats.report()) + for host in conf.hosts: + with ClientConnection(*splitHost(host,conf.port)) as con: + c.setConnection(con) + blocksToTransfer=c.negotiate() + c.sendData(blocksToTransfer) + print() + print(stats.report()) def pull(args): _checkFile(args.datafile) if args.tree: _checkFile(args.tree) - if args.host: conf.hosts.insert(0,args.host) + if args.host: conf.hosts=[args.host] if args.port: conf.port=args.port c=Client(args.datafile,args.tree) - with ClientConnection() as con: + with ClientConnection(*splitHost(conf.hosts[0],conf.port)) as con: c.setConnection(con) blocksToTransfer=c.negotiate() c.pullData(blocksToTransfer)