diff options
author | Kelvin Zhang <zhangkelvin@google.com> | 2021-11-22 21:20:58 -0800 |
---|---|---|
committer | Kelvin Zhang <zhangkelvin@google.com> | 2021-11-22 21:22:14 -0800 |
commit | 64c6fd95f67520dae5286423c24d682f7a2eb1ba (patch) | |
tree | b5f9d714790e53787e035d64e91cdeadda7b501c /ext4_utils | |
parent | b61c66e9bc6637db70eeb1b83429619a6aa13322 (diff) | |
download | extras-64c6fd95f67520dae5286423c24d682f7a2eb1ba.tar.gz |
Convert mkuserimg_mke2fs to python3
1. Use // to ensure division output is integer
2. Specify text=True so that output of subprocess is str not bytes
Test: th
Change-Id: I7b99598e96d460318c0a65853816b1c8fba899ce
Diffstat (limited to 'ext4_utils')
-rw-r--r-- | ext4_utils/Android.bp | 6 | ||||
-rw-r--r-- | ext4_utils/mkuserimg_mke2fs.py | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/ext4_utils/Android.bp b/ext4_utils/Android.bp index 80f70b9a..53e08d78 100644 --- a/ext4_utils/Android.bp +++ b/ext4_utils/Android.bp @@ -71,14 +71,10 @@ python_binary_host { ], version: { - py2: { + py3: { enabled: true, embedded_launcher: true, }, - py3: { - enabled: false, - embedded_launcher: false, - }, }, required: [ diff --git a/ext4_utils/mkuserimg_mke2fs.py b/ext4_utils/mkuserimg_mke2fs.py index d4a14f87..599e40ee 100644 --- a/ext4_utils/mkuserimg_mke2fs.py +++ b/ext4_utils/mkuserimg_mke2fs.py @@ -41,7 +41,7 @@ def RunCommand(cmd, env): logging.info("Running: " + " ".join(cmd)) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - env=env_copy) + env=env_copy, text=True) output, _ = p.communicate() return output, p.returncode @@ -169,7 +169,7 @@ def ConstructE2fsCommands(args): if args.flash_logical_block_size: # stride should be the max of 8kb and the logical block size stride = max(int(args.flash_logical_block_size), 8192) - mke2fs_extended_opts.append("stride={}".format(stride / BLOCKSIZE)) + mke2fs_extended_opts.append("stride={}".format(stride // BLOCKSIZE)) if args.mke2fs_hash_seed: mke2fs_extended_opts.append("hash_seed=" + args.mke2fs_hash_seed) @@ -194,7 +194,7 @@ def ConstructE2fsCommands(args): mke2fs_opts += ["-E", ','.join(mke2fs_extended_opts)] # Round down the filesystem length to be a multiple of the block size - blocks = int(args.fs_size) / BLOCKSIZE + blocks = int(args.fs_size) // BLOCKSIZE mke2fs_cmd = (["mke2fs"] + mke2fs_opts + ["-t", args.ext_variant, "-b", str(BLOCKSIZE), args.output_file, str(blocks)]) |