File e47b34c0-Fix-initrdinject-and-urltests-with-py3.patch of Package virt-manager.10841

Subject: Fix initrdinject and urltests with py3
From: Cole Robinson crobinso@redhat.com Sat Jan 27 15:23:22 2018 -0500
Date: Tue Feb 6 18:56:15 2018 -0500:
Git: e47b34c05af5af15906f15e4098d4d69c8251b59

A few random issues scattered about

Index: virt-manager-1.5.1/virtinst/initrdinject.py
===================================================================
--- virt-manager-1.5.1.orig/virtinst/initrdinject.py
+++ virt-manager-1.5.1/virtinst/initrdinject.py
@@ -29,7 +29,8 @@ def _rhel4_initrd_inject(initrd, injecti
         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, injecti
     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, injecti
                                         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:
Index: virt-manager-1.5.1/virtinst/progress.py
===================================================================
--- virt-manager-1.5.1.orig/virtinst/progress.py
+++ virt-manager-1.5.1/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,
Index: virt-manager-1.5.1/virtinst/urlfetcher.py
===================================================================
--- virt-manager-1.5.1.orig/virtinst/urlfetcher.py
+++ virt-manager-1.5.1/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 = urlparse.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):
openSUSE Build Service is sponsored by