summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2018-01-27 15:23:22 -0500
committerCole Robinson <crobinso@redhat.com>2018-02-06 18:56:15 -0500
commite47b34c05af5af15906f15e4098d4d69c8251b59 (patch)
tree7d73d0b288ab75219bf2b550e6b32d0dbb1f60ed
parentb8e2952a9c188e1b4302690585339f89a1c67bb2 (diff)
downloadvirt-manager-e47b34c05af5af15906f15e4098d4d69c8251b59.tar.gz
Fix initrdinject and urltests with py3
A few random issues scattered about
-rw-r--r--virtinst/initrdinject.py7
-rw-r--r--virtinst/progress.py1
-rw-r--r--virtinst/urlfetcher.py6
3 files changed, 8 insertions, 6 deletions
diff --git a/virtinst/initrdinject.py b/virtinst/initrdinject.py
index bf433c44..84e40a56 100644
--- a/virtinst/initrdinject.py
+++ b/virtinst/initrdinject.py
@@ -29,7 +29,8 @@ def _rhel4_initrd_inject(initrd, injections):
file_proc = subprocess.Popen(["file", "-z", initrd],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- if "ext2 filesystem" not in file_proc.communicate()[0]:
+ s = bytes("ext2 filesystem", "ascii")
+ if s not in file_proc.communicate()[0]:
return False
except Exception:
logging.exception("Failed to file command for rhel4 initrd detection")
@@ -45,7 +46,7 @@ def _rhel4_initrd_inject(initrd, injections):
gzip_proc.wait()
newinitrd.close()
- debugfserr = ""
+ debugfserr = bytes()
for filename in injections:
# We have an ext2 filesystem, use debugfs to inject files
cmd = ["debugfs", "-w", "-R",
@@ -57,7 +58,7 @@ def _rhel4_initrd_inject(initrd, injections):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
debugfs_proc.wait()
- debugfserr += debugfs_proc.stderr.read() or ""
+ debugfserr += debugfs_proc.stderr.read() or bytes()
gziperr = gzip_proc.stderr.read()
if gziperr:
diff --git a/virtinst/progress.py b/virtinst/progress.py
index 779b3711..29bff358 100644
--- a/virtinst/progress.py
+++ b/virtinst/progress.py
@@ -473,6 +473,7 @@ def format_number(number, SI=0, space=' '):
thresh = 999
depth = 0
max_depth = len(symbols) - 1
+ number = number or 0
# we want numbers between 0 and thresh, but don't exceed the length
# of our list. In that event, the formatting will be screwed up,
diff --git a/virtinst/urlfetcher.py b/virtinst/urlfetcher.py
index 16310005..495c3f6a 100644
--- a/virtinst/urlfetcher.py
+++ b/virtinst/urlfetcher.py
@@ -170,7 +170,7 @@ class _URLFetcher(object):
"""
fileobj = io.BytesIO()
self._grabURL(filename, fileobj)
- return fileobj.getvalue()
+ return fileobj.getvalue().decode("utf-8")
class _HTTPURLFetcher(_URLFetcher):
@@ -221,7 +221,7 @@ class _FTPURLFetcher(_URLFetcher):
try:
parsed = urllib.parse.urlparse(self.location)
self._ftp = ftplib.FTP()
- self._ftp.connect(parsed.hostname, parsed.port)
+ self._ftp.connect(parsed.hostname, parsed.port or 0)
self._ftp.login()
# Force binary mode
self._ftp.voidcmd("TYPE I")
@@ -359,7 +359,7 @@ class _ISOURLFetcher(_URLFetcher):
self._cache_file_list = output.splitlines(False)
- return url in self._cache_file_list
+ return url.encode("ascii") in self._cache_file_list
def fetcherForURI(uri, *args, **kwargs):