Skip to content

Commit

Permalink
Copy urlgrabber progress bar code into virt-manager.git
Browse files Browse the repository at this point in the history
This is so we can drop the dep on system python-urlgrabber, which will
block us from going to python3.

All we need is like 300 lines from python-urlgrabber for the progress
bar. In reality our needs are much lower, we don't need the fancy
progress bar that urlgrabber provides, but it's nice to have. So if
keeping a copy of this code causes issues in the future, we can probably
come up with something simpler (or hopefully there's a more common
python progressbar impl that we can use at that point).
  • Loading branch information
crobinso committed Sep 19, 2015
1 parent 5584863 commit d5d6cff
Show file tree
Hide file tree
Showing 5 changed files with 511 additions and 9 deletions.
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,17 +567,23 @@ def run(self):
"tests"]

output_format = sys.stdout.isatty() and "colorized" or "text"
exclude = ["virtinst/progress.py"]

print "running pep8"
cmd = "pep8 "
cmd += "--config tests/pep8.cfg "
cmd += "--exclude %s " % ",".join(exclude)
cmd += " ".join(files)
os.system(cmd + " --config tests/pep8.cfg")
os.system(cmd)

print "running pylint"
cmd = "pylint "
cmd += "--rcfile tests/pylint.cfg "
cmd += "--output-format=%s " % output_format
cmd += "--ignore %s " % ",".join(
[os.path.basename(p) for p in exclude])
cmd += " ".join(files)
os.system(cmd + " --rcfile tests/pylint.cfg")
os.system(cmd)


setup(
Expand Down
1 change: 0 additions & 1 deletion virt-manager.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ Group: Applications/Emulators
Requires: libvirt-python >= 0.7.0
Requires: libxml2-python
Requires: python-requests
Requires: python-urlgrabber
Requires: python-ipaddr
Requires: libosinfo >= 0.2.10
# Required for gobject-introspection infrastructure
Expand Down
11 changes: 6 additions & 5 deletions virtManager/asyncjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
from gi.repository import Gtk

import libvirt
import urlgrabber.progress

import virtinst.progress

from .baseclass import vmmGObjectUI


class vmmMeter(urlgrabber.progress.BaseMeter):
class vmmMeter(virtinst.progress.BaseMeter):
def __init__(self, cb_pulse, cb_fraction, cb_done):
urlgrabber.progress.BaseMeter.__init__(self)
virtinst.progress.BaseMeter.__init__(self)
self.started = False

self._vmm_pulse = cb_pulse
Expand All @@ -60,7 +61,7 @@ def _do_update(self, amount_read, now=None):
text = self.text
else:
text = self.basename
fread = urlgrabber.progress.format_number(amount_read)
fread = virtinst.progress.format_number(amount_read)
if self.size is None:
out = " %5sB" % (fread)
self._vmm_pulse(out, text)
Expand All @@ -74,7 +75,7 @@ def _do_end(self, amount_read, now=None):
text = self.text
else:
text = self.basename
fread = urlgrabber.progress.format_number(amount_read)
fread = virtinst.progress.format_number(amount_read)
if self.size is None:
out = " %5sB" % (fread)
self._vmm_pulse(out, text)
Expand Down
Loading

0 comments on commit d5d6cff

Please sign in to comment.