mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 21:18:04 +03:00
Fix initrdinject and urltests with py3
A few random issues scattered about
This commit is contained in:
parent
b8e2952a9c
commit
e47b34c05a
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user