Commit Graph

35 Commits

Author SHA1 Message Date
Cole Robinson 078178f476 progress: Drop tqdm and revert back to local urlgrabber copy
I thought tqdm was available everywhere, but it does not seem like
it will be in RHEL9. Revert back to the old urlgrabber copy, now
stored in virtinst/_progresspriv.py. If we ever want to try tqdm
again, we can just revert this commit

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2021-06-09 16:52:11 -04:00
Cole Robinson 2024068be8 progress: convert to tqdm
tqdm is an external library that provides a progress bar
implementation. Switch to it and drop our internal copy of the
old urlgrabber progressbar

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2021-05-22 14:56:10 -04:00
Cole Robinson 6659889319 progress: Some internal API cleanup
* Simplify start() and end() function signature
* Drop use of 'basename' and standardize on 'text'
* Add vmmMeter.is_started()
* Add vmmMeter.set_text()
* Fix asyncjob UI to show text in the progress bar

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2021-05-22 14:56:10 -04:00
Daniel Henrique Barboza 29963ac986 virtinst/progress.py: change 'fo' to make codespell happy
'codespell' returns errors on this file in the format of:

virtinst/progress.py:527: fo  ==> of, for

This has to do with the 'fo' instance variable of the TextMeter
class. The code was introduced in commit v1.2.1-131-gd5d6cfff,
when parts of the urlgrabber code were copied to avoid dependency
on python-urlgrabber.

Looking at how 'fo' is used, an alternative would be rename it to
'output', so let's make codespell and ourselves happier with less
lint errors.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-07-04 17:56:57 -04:00
Cole Robinson c603ea4084 util: Move *_meter to progress.py 2019-06-07 17:32:51 -04:00
Radostin Stoyanov f53e5b024d progress: Remove commented out code
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov 45d76ccadd progress: Resolve protected-access
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov 0505f2be3d progress: Resolve E226
E226: missing whitespace around arithmetic operator

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov 48255ea584 progress: Don't use black-listed name 'bar'
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov 6a66d8cce0 progress: Resolve E502
E502: the backslash is redundant between brackets

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov 5e6b73d439 progress: Resolve E501 and E305
E501: line too long (82 > 79 characters)
E305: expected 2 blank lines after end of function or class

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov e7a3a55f2d progress: Resolve E231
E231: missing whitespace after ‘,’, ‘;’, or ‘:’

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov a7254aa006 progress: Resolve E129
E129: visually indented line with same indent as next logical line

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov 19b3d2ac66 progress: Resolve E714
E714: test for object identity should be ‘is not’

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov 6d125cca72 progress: Resolve E265
E265: block comment should start with ‘# ‘

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov 3468a2ec1f progress: Resolve E722
E722: do not use bare except, specify exception instead

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov c3453422f2 progress: Resolve E261
E261: at least two spaces before inline comment

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov cd1a46c2ae progress: Resolve E701
E701: multiple statements on one line (colon)

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov 9a472f506d progress: Resolve E221
E221: multiple spaces before operator

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov ed98a29dda progress: Resolve E302
E302: expected 2 blank lines

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Radostin Stoyanov b7c7c27f7c progress: Resolve W0201
W0201: Attribute %r defined outside __init__

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-11-12 08:34:55 -05:00
Stefan Weil 633534c8b8 Fix some typos in comments and documentation (found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-06-05 14:27:29 -04:00
Daniel P. Berrangé b1460ba065 Chagne most URIs to use https:// instead of http://
All URLs were checked to see if they supported https://, those which did
were converted.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-30 13:35:39 -04:00
Daniel P. Berrangé 48e32b429d Fix copyright header to specify GPLv2 or later, not GPLv2 only.
The copyright headers in every file were chjanged in this previous commit

  commit b6dcee8eb7
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Tue Mar 20 15:00:02 2018 -0400

    Use consistent and minimal license header for every file

Where before this they said "

  "either version 2 of the License, or (at your option) any later version."

Now they just say

  "GNU GPLv2"

This fixes it to say "GNU GPLv2 or later" again.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-04 16:51:37 -04:00
Cole Robinson b6dcee8eb7 Use consistent and minimal license header for every file 2018-03-21 07:29:40 -04:00
Radostin Stoyanov 8ebab1f27e virtinst: progress: Simplify if-statement
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-03-03 16:24:02 -05:00
Cole Robinson e47b34c05a Fix initrdinject and urltests with py3
A few random issues scattered about
2018-02-06 18:56:15 -05:00
Radostin Stoyanov 95c695d774 Convert long to int
- Python 2 only
k = 9223372036854775808L

- Python 2 and 3:
k = 9223372036854775808

See http://python-future.org/compatible_idioms.html#long-integers
2018-02-06 18:49:17 -05:00
Radostin Stoyanov 6712261510 Python 2/3 division compatability
In Python 2 the classic devision of integers returns an integer
but in Python 3 it might return float.

Example:
- Python 2:          - Python 3:
    >>> 9 / 4            >>> 9 / 4
    2                    2.25
    >>> 9 // 4           >>> 9 // 4
    2                    2
    >>> 9 / 4.0          >>> 9 / 4.0
    2.25                 2.25
    >>> 9 // 4.0         >>> 9 // 4.0
    2.0                  2.0

For more info see: https://www.python.org/dev/peps/pep-0238/
2018-01-27 15:30:17 -05:00
Radostin Stoyanov 2d276ebed8 progress: Don't overwrite "format"
Do not overwrite built-in format. [1]

https://docs.python.org/2/library/functions.html#format
2017-10-20 11:49:14 -04:00
Radostin Stoyanov bc3c9a9d7b progress: Remove unused import 2017-10-20 11:49:14 -04:00
Radostin Stoyanov 63fce081ed pycodestyle: Use isinstance() for type checking
This is E721 in pycodestyle [1]:
   "do not compare types, use ‘isinstance()’"

The main differece between "type() is" and "isinstance()" is that
isinstance() supports inheritance. [1]

This can be seen in the example below:
    >>> type(True) is int
    False
    >>> isinstance(True, int)
    True

As we can see in python 'bool' a subclass of 'int'.

[1] https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
[2] https://docs.python.org/2/library/functions.html#isinstance
2017-10-20 11:49:13 -04:00
Radostin Stoyanov d1e1cf64a7 progress: Remove trailing white space 2017-10-20 11:49:12 -04:00
Cole Robinson fab55c128f Drop use of python2 long() syntax
Plus one more python3 syntax issue
2017-05-05 14:54:35 -04:00
Cole Robinson d5d6cfff2c Copy urlgrabber progress bar code into virt-manager.git
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).
2015-09-18 20:55:44 -04:00