From 9464fa91fca0b3e4073e6eee3ea1bdae54e48131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=9F=D1=80?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B7=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 22 Feb 2019 14:15:58 +0400 Subject: [PATCH] Added support for sending block devices --- src/wormhole/cli/cmd_send.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index e97fc8b..7c6925e 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -3,6 +3,8 @@ from __future__ import print_function import hashlib import os import sys + +import stat import tempfile import zipfile @@ -364,6 +366,22 @@ class Sender: file=args.stderr) return offer, fd_to_send + if stat.S_ISBLK(os.stat(what).st_mode): + fd_to_send = open(what, "rb") + filesize = fd_to_send.seek(0, 2) + + offer["file"] = { + "filename": basename, + "filesize": filesize, + } + print( + u"Sending %s block device named '%s'" % (naturalsize(filesize), + basename), + file=args.stderr) + + fd_to_send.seek(0) + return offer, fd_to_send + raise TypeError("'%s' is neither file nor directory" % args.what) @inlineCallbacks