Richard Cooper has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/39895 )
Change subject: misc: Update util/gem5img.py to work with python3 and
python2.
......................................................................
misc: Update util/gem5img.py to work with python3 and python2.
Tested on Ubuntu 18.04 with Python 3.6.8 and Python 2.7.15+.
Change-Id: Ic8b407ad41dc0d6d37a54a54eeef2b9156d893d6
---
M util/gem5img.py
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/util/gem5img.py b/util/gem5img.py
index 03d1f3f..e251210 100755
--- a/util/gem5img.py
+++ b/util/gem5img.py
@@ -30,6 +30,8 @@
# Script for managing a gem5 disk image.
#
+from __future__ import print_function
+
from optparse import OptionParser
import os
from os import environ as env
@@ -86,7 +88,7 @@
def runCommand(command, inputVal=''):
print("%>", ' '.join(command))
proc = Popen(command, stdin=PIPE)
- proc.communicate(inputVal)
+ proc.communicate(inputVal.encode())
return proc.returncode
# Run an external command and capture its output. This is intended to be
@@ -98,7 +100,7 @@
proc = Popen(command, stderr=STDOUT,
stdin=PIPE, stdout=PIPE)
(out, err) = proc.communicate(inputVal)
- return (out, proc.returncode)
+ return (out.decode(), proc.returncode)
# Run a command as root, using sudo if necessary.
def runPriv(command, inputVal=''):
@@ -120,7 +122,7 @@
if cleanupDev:
cleanupDev.destroy()
exit("Unable to find program %s, check your PATH variable." %
program)
- return string.strip(out)
+ return out.strip()
class LoopbackDevice(object):
def __init__(self, devFile=None):
@@ -134,7 +136,7 @@
if returncode != 0:
print(out)
return returncode
- self.devFile = string.strip(out)
+ self.devFile = out.strip()
command = [findProg('losetup'), self.devFile, fileName]
if offset:
off = findPartOffset(self.devFile, fileName, 0)
@@ -299,11 +301,11 @@
# store to disk and which is defined to read as zero.
fd = os.open(file, os.O_WRONLY | os.O_CREAT)
os.lseek(fd, size - 1, os.SEEK_SET)
- os.write(fd, '\0')
+ os.write(fd, b'\0')
def newComFunc(options, args):
(file, mb) = args
- mb = string.atoi(mb)
+ mb = int(mb)
newImage(file, mb)
@@ -366,7 +368,7 @@
def initComFunc(options, args):
(path, mb) = args
- mb = string.atoi(mb)
+ mb = int(mb)
newImage(path, mb)
dev = LoopbackDevice()
if dev.setup(path) != 0:
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39895
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ic8b407ad41dc0d6d37a54a54eeef2b9156d893d6
Gerrit-Change-Number: 39895
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Cooper <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s