Symbol: Python 3 compatibility
Fix some minor issues. Test: symbol test Change-Id: Iaa9f304c079abfc26212de8213fba38f4e311ec1
This commit is contained in:
@@ -28,18 +28,21 @@ import signal
|
|||||||
import subprocess
|
import subprocess
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
ANDROID_BUILD_TOP = os.environ["ANDROID_BUILD_TOP"]
|
ANDROID_BUILD_TOP = str(os.environ["ANDROID_BUILD_TOP"])
|
||||||
if not ANDROID_BUILD_TOP:
|
if not ANDROID_BUILD_TOP:
|
||||||
ANDROID_BUILD_TOP = "."
|
ANDROID_BUILD_TOP = "."
|
||||||
|
|
||||||
def FindSymbolsDir():
|
def FindSymbolsDir():
|
||||||
saveddir = os.getcwd()
|
saveddir = os.getcwd()
|
||||||
os.chdir(ANDROID_BUILD_TOP)
|
os.chdir(ANDROID_BUILD_TOP)
|
||||||
|
stream = None
|
||||||
try:
|
try:
|
||||||
cmd = "build/soong/soong_ui.bash --dumpvar-mode --abs TARGET_OUT_UNSTRIPPED"
|
cmd = "build/soong/soong_ui.bash --dumpvar-mode --abs TARGET_OUT_UNSTRIPPED"
|
||||||
stream = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).stdout
|
stream = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).stdout
|
||||||
return os.path.join(ANDROID_BUILD_TOP, stream.read().strip())
|
return os.path.join(ANDROID_BUILD_TOP, str(stream.read().strip()))
|
||||||
finally:
|
finally:
|
||||||
|
if stream is not None:
|
||||||
|
stream.close()
|
||||||
os.chdir(saveddir)
|
os.chdir(saveddir)
|
||||||
|
|
||||||
SYMBOLS_DIR = FindSymbolsDir()
|
SYMBOLS_DIR = FindSymbolsDir()
|
||||||
@@ -166,7 +169,7 @@ def FindToolchain():
|
|||||||
|
|
||||||
_CACHED_TOOLCHAIN = toolchain
|
_CACHED_TOOLCHAIN = toolchain
|
||||||
_CACHED_TOOLCHAIN_ARCH = ARCH
|
_CACHED_TOOLCHAIN_ARCH = ARCH
|
||||||
print "Using %s toolchain from: %s" % (_CACHED_TOOLCHAIN_ARCH, _CACHED_TOOLCHAIN)
|
print("Using %s toolchain from: %s" % (_CACHED_TOOLCHAIN_ARCH, _CACHED_TOOLCHAIN))
|
||||||
return _CACHED_TOOLCHAIN
|
return _CACHED_TOOLCHAIN
|
||||||
|
|
||||||
|
|
||||||
@@ -717,7 +720,13 @@ class SetArchTests(unittest.TestCase):
|
|||||||
def test_no_abi(self):
|
def test_no_abi(self):
|
||||||
global ARCH
|
global ARCH
|
||||||
|
|
||||||
self.assertRaisesRegexp(Exception, "Could not determine arch from input, use --arch=XXX to specify it", SetAbi, [])
|
# Python2 vs Python3 compatibility: Python3 warns on Regexp deprecation, but Regex
|
||||||
|
# does not provide that name.
|
||||||
|
if not hasattr(unittest.TestCase, 'assertRaisesRegex'):
|
||||||
|
unittest.TestCase.assertRaisesRegex = getattr(unittest.TestCase, 'assertRaisesRegexp')
|
||||||
|
self.assertRaisesRegex(Exception,
|
||||||
|
"Could not determine arch from input, use --arch=XXX to specify it",
|
||||||
|
SetAbi, [])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main(verbosity=2)
|
||||||
|
|||||||
Reference in New Issue
Block a user