#!/usr/bin/python3 # Copyright (C) 2012-2016 # # * Volker Diels-Grabsch # * art0int # * guillaume # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. import hashlib import os import os.path import struct import subprocess import sys # device_function: filters or transforms device names device_function = lambda dev : dev # remote_command: command to run bscp on the remote host remote_command = __file__ def serve(): global allowed_devices (size, blocksize, filename_len, hashname_len) = struct.unpack('= 4: blocksize = int(sys.argv[3]) else: blocksize = 64 * 1024 if len(sys.argv) >= 5: hashname = sys.argv[4] else: hashname = 'sha1' assert len(sys.argv) <= 5 except: usage = 'bscp SRC HOST:DEST [BLOCKSIZE] [HASH]' sys.stderr.write('Usage:\n\n %s\n\n' % (usage,)) sys.exit(1) (in_total, out_total, size) = bscp(local_filename, remote_host, remote_filename, blocksize, hashname) speedup = size * 1.0 / (in_total + out_total) sys.stderr.write('in=%i out=%i size=%i speedup=%.2f\n' % (in_total, out_total, size, speedup))