headers was initialized with a set literal {"key", "value"} instead
of
dict literal {"key": "value"}.
Calling pread() will fail with:
AttributeError: 'set' object has no attribute 'items'
I did not test the changed code, but it was not tested before, so it is
unlikely to be worse.
Detected by pylint.
---
v2v/rhv-upload-plugin.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
index 3272c3ce3..e651bc686 100644
--- a/v2v/rhv-upload-plugin.py
+++ b/v2v/rhv-upload-plugin.py
@@ -321,41 +321,41 @@ def request_failed(h, r, msg):
body = "(Unable to read response body: %s)" % e
# Log the full error if we're verbose.
debug("unexpected response from imageio server:")
debug(msg)
debug("%d: %s" % (status, reason))
debug(body)
# Only a short error is included in the exception.
raise RuntimeError("%s: %d %s: %r" % (msg, status, reason, body[:200]))
# For documentation see:
#
https://github.com/oVirt/ovirt-imageio/blob/master/docs/random-io.md
# For examples of working code to read/write from the server, see:
#
https://github.com/oVirt/ovirt-imageio/blob/master/daemon/test/server_tes...
def pread(h, count, offset):
http = h['http']
transfer = h['transfer']
- headers = {"Range", "bytes=%d-%d" % (offset, offset+count-1)}
+ headers = {"Range": "bytes=%d-%d" % (offset, offset+count-1)}
if h['needs_auth']:
headers["Authorization"] = transfer.signed_ticket
http.request("GET", h['path'], headers=headers)
r = http.getresponse()
# 206 = HTTP Partial Content.
if r.status != 206:
request_failed(h, r,
"could not read sector offset %d size %d" %
(offset, count))
return r.read()
def pwrite(h, buf, offset):
http = h['http']
transfer = h['transfer']
count = len(buf)
h['highestwrite'] = max(h['highestwrite'], offset+count)
--
2.17.2