diff options
author | Radostin Stoyanov <rstoyanov1@gmail.com> | 2017-07-05 14:44:24 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cbosdonnat@suse.com> | 2017-07-05 16:55:15 +0200 |
commit | 971313ccb67068035622b3f5bbcf8737e9aeee80 (patch) | |
tree | 57cb1c2c6d154691e60ab0de5f3d2b292f968d1a /src/virtBootstrap/virt_bootstrap.py | |
parent | 0095aca7457911d8515967fd03cd53f76abd465e (diff) | |
download | virt-bootstrap.git-971313ccb67068035622b3f5bbcf8737e9aeee80.tar.gz virt-bootstrap.git-971313ccb67068035622b3f5bbcf8737e9aeee80.tar.xz virt-bootstrap.git-971313ccb67068035622b3f5bbcf8737e9aeee80.zip |
Gather common utility functions in "utils" module
Add new module to collect utility functions used in virt-bootstrap.
Move the function definitions from "sources" and "virt_bootstrap" to
the new module.
Diffstat (limited to 'src/virtBootstrap/virt_bootstrap.py')
-rwxr-xr-x | src/virtBootstrap/virt_bootstrap.py | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/virtBootstrap/virt_bootstrap.py b/src/virtBootstrap/virt_bootstrap.py index b2a32d7..85aca33 100755 --- a/src/virtBootstrap/virt_bootstrap.py +++ b/src/virtBootstrap/virt_bootstrap.py @@ -35,6 +35,7 @@ except ImportError: from virtBootstrap import sources from virtBootstrap import progress +from virtBootstrap import utils gettext.bindtextdomain("virt-bootstrap", "/usr/share/locale") @@ -81,25 +82,6 @@ def set_root_password(rootfs, password): raise CalledProcessError(chpasswd.returncode, cmd=args, output=None) -def write_progress(prog): - """ - Write progress output to console - """ - # Get terminal width - try: - terminal_width = int(Popen(["stty", "size"], stdout=PIPE).stdout - .read().split()[1]) - except Exception: - terminal_width = 80 - # Prepare message - msg = "\rStatus: %s, Progress: %.2f%%" % (prog['status'], prog['value']) - # Fill with whitespace and return cursor at the begging - msg = "%s\r" % msg.ljust(terminal_width) - # Write message to console - sys.stdout.write(msg) - sys.stdout.flush() - - # pylint: disable=too-many-arguments def bootstrap(uri, dest, fmt='dir', @@ -199,7 +181,7 @@ def main(): help=_("Suppresses messages notifying about" "current state or actions of virt-bootstrap")) parser.add_argument("--status-only", action="store_const", - const=write_progress, + const=utils.write_progress, help=_("Show only the current status and progress" "of virt-bootstrap")) |