Skip to content Skip to sidebar Skip to footer

Python Openstack Sdk Show File Upload Via Progress Bar

With the python openstack SDK, you can download an image, chunk by chunk, which allowed me to show a progress bar. You can't seem to do the same when uploading a file. What I want

Solution 1:

So, after quite a bit of searching I was able to find a way to do what I was asking (here & here).

code:

#!/usr/bin/env python3from types import MethodType

defhook(hookfunk, oldfunc):
    defmerged(self, *args, **kwargs):
        hookfunk(self, *args, **kwargs)
        return oldfunc(*args, **kwargs)
    return  MethodType(merged, oldfunc.__self__)


f = open('cirros.qcow2', 'rb')

defnew_read(self, size):
    print(self)
    # Or do other code, like updating a progress bar

f.read = hook(new_read, f.read)

f.read()

Post a Comment for "Python Openstack Sdk Show File Upload Via Progress Bar"