Commit 717b0434 authored by Nikos Skalkotos's avatar Nikos Skalkotos

Support python-sendfile 2.x

Support both versions (1.2.x and 2.x) of python-sendfile. In
v1.2.x (py-sendfile) the returning value of the sendfile function is a
tuple, where in v2.x (pysendfile) it's a simple integer.
parent 0d7d3237
......@@ -480,8 +480,15 @@ class DiskDevice(object):
progressbar.next()
while left > 0:
length = min(left, blocksize)
_, sent = sendfile(dst.fileno(), src.fileno(), offset,
length)
sent = sendfile(dst.fileno(), src.fileno(), offset, length)
# Workaround for python-sendfile API change. In
# python-sendfile 1.2.x (py-sendfile) the returning value
# of sendfile is a tuple, where in version 2.x (pysendfile)
# it is just a sigle integer.
if isinstance(sent, tuple):
sent = sent[1]
offset += sent
left -= sent
progressbar.goto((size - left) // MB)
......
......@@ -48,7 +48,7 @@ setup(
license='BSD',
packages=find_packages(),
include_package_data=True,
install_requires=['sh', 'ansicolors', 'progress>=1.0.2', 'py-sendfile'],
install_requires=['sh', 'ansicolors', 'progress>=1.0.2'],
entry_points={
'console_scripts': [
'snf-image-creator = image_creator.main:main',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment