preliminary refactoring
This commit is contained in:
parent
1428507909
commit
6958241f3f
|
@ -31,20 +31,21 @@ def send(args):
|
||||||
return 1
|
return 1
|
||||||
# we're sending a file
|
# we're sending a file
|
||||||
sending_message = False
|
sending_message = False
|
||||||
filesize = os.stat(args.what).st_size
|
|
||||||
basename = os.path.basename(args.what)
|
|
||||||
print("Sending %d byte file named '%s'" % (filesize, basename))
|
|
||||||
transit_sender = TransitSender(args.transit_helper)
|
transit_sender = TransitSender(args.transit_helper)
|
||||||
phase1 = {
|
phase1 = {
|
||||||
"file": {
|
|
||||||
"filename": basename,
|
|
||||||
"filesize": filesize,
|
|
||||||
},
|
|
||||||
"transit": {
|
"transit": {
|
||||||
"direct_connection_hints": transit_sender.get_direct_hints(),
|
"direct_connection_hints": transit_sender.get_direct_hints(),
|
||||||
"relay_connection_hints": transit_sender.get_relay_hints(),
|
"relay_connection_hints": transit_sender.get_relay_hints(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
filesize = os.stat(args.what).st_size
|
||||||
|
basename = os.path.basename(args.what)
|
||||||
|
print("Sending %d byte file named '%s'" % (filesize, basename))
|
||||||
|
fd_to_send = open(args.what, "rb")
|
||||||
|
phase1["file"] = {
|
||||||
|
"filename": basename,
|
||||||
|
"filesize": filesize,
|
||||||
|
}
|
||||||
|
|
||||||
with Wormhole(APPID, args.relay_url) as w:
|
with Wormhole(APPID, args.relay_url) as w:
|
||||||
if args.zeromode:
|
if args.zeromode:
|
||||||
|
@ -114,7 +115,7 @@ def send(args):
|
||||||
print("Sending (%s).." % transit_sender.describe())
|
print("Sending (%s).." % transit_sender.describe())
|
||||||
|
|
||||||
CHUNKSIZE = 64*1024
|
CHUNKSIZE = 64*1024
|
||||||
with open(args.what, "rb") as f:
|
with fd_to_send as f:
|
||||||
sent = 0
|
sent = 0
|
||||||
next_update = start_progress(filesize)
|
next_update = start_progress(filesize)
|
||||||
while sent < filesize:
|
while sent < filesize:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user