Remove py-six dependecie: convert string to bytes.
Bug: 223079136
Test: bash run_tests.sh
Change-Id: I7cce6563e88c381e8d55949c95e1772e1f38856a
diff --git a/internal/lib/adb_tools_test.py b/internal/lib/adb_tools_test.py
index a3ebf44..cc46ca3 100644
--- a/internal/lib/adb_tools_test.py
+++ b/internal/lib/adb_tools_test.py
@@ -17,7 +17,6 @@
import unittest
from unittest import mock
-from six import b
from acloud import errors
from acloud.internal.lib import adb_tools
@@ -26,16 +25,16 @@
class AdbToolsTest(driver_test_lib.BaseDriverTest):
"""Test adb functions."""
- DEVICE_ALIVE = b("List of devices attached\n"
- "127.0.0.1:48451 device product:aosp_cf_x86_phone "
- "model:Cuttlefish_x86_phone device:vsoc_x86 "
- "transport_id:98")
- DEVICE_OFFLINE = b("List of devices attached\n"
- "127.0.0.1:48451 offline")
- DEVICE_STATE_ONLY = b("List of devices attached\n"
- "127.0.0.1:48451\toffline\n"
- "emulator-5554\tdevice\n")
- DEVICE_NONE = b("List of devices attached")
+ DEVICE_ALIVE = ("List of devices attached\n"
+ "127.0.0.1:48451 device product:aosp_cf_x86_phone "
+ "model:Cuttlefish_x86_phone device:vsoc_x86 "
+ "transport_id:98").encode()
+ DEVICE_OFFLINE = ("List of devices attached\n"
+ "127.0.0.1:48451 offline").encode()
+ DEVICE_STATE_ONLY = ("List of devices attached\n"
+ "127.0.0.1:48451\toffline\n"
+ "emulator-5554\tdevice\n").encode()
+ DEVICE_NONE = b"List of devices attached"
def setUp(self):
"""Patch the path to adb."""
diff --git a/internal/lib/ota_tools.py b/internal/lib/ota_tools.py
index 8d613c8..edfe23f 100644
--- a/internal/lib/ota_tools.py
+++ b/internal/lib/ota_tools.py
@@ -17,9 +17,6 @@
import os
import tempfile
-from six import b
-
-
from acloud import errors
from acloud.internal.lib import utils
@@ -166,18 +163,18 @@
if split_line[0] == "dynamic_partition_list":
partition_names = split_line[1].split()
elif split_line[0] == "lpmake":
- output_file.write(b("lpmake=%s\n" % lpmake_path))
+ output_file.write("lpmake=%s\n" % lpmake_path)
continue
elif split_line[0].endswith("_image"):
continue
- output_file.write(b(line))
+ output_file.write(line)
if not partition_names:
logger.w("No dynamic partition list in misc info.")
for partition_name in partition_names:
- output_file.write(b("%s_image=%s\n" %
- (partition_name, get_image(partition_name))))
+ output_file.write("%s_image=%s\n" %
+ (partition_name, get_image(partition_name)))
@utils.TimeExecute(function_description="Build super image")
@utils.TimeoutException(_BUILD_SUPER_IMAGE_TIMEOUT_SECS)
@@ -199,7 +196,7 @@
with open(misc_info_path, "r") as misc_info:
with tempfile.NamedTemporaryFile(
prefix="misc_info_", suffix=".txt",
- delete=False) as new_misc_info:
+ delete=False, mode="w") as new_misc_info:
new_misc_info_path = new_misc_info.name
self._RewriteMiscInfo(new_misc_info, misc_info, lpmake,
get_image)
@@ -247,11 +244,11 @@
for line in input_file:
split_line = line.split()
if len(split_line) == 3:
- output_file.write(b("%s %s %s\n" % (get_image(split_line[1]),
- split_line[1],
- split_line[2])))
+ output_file.write("%s %s %s\n" % (get_image(split_line[1]),
+ split_line[1],
+ split_line[2]))
else:
- output_file.write(b(line))
+ output_file.write(line)
@utils.TimeExecute(function_description="Make combined image")
@utils.TimeoutException(_MK_COMBINED_IMG_TIMEOUT_SECS)
@@ -274,7 +271,7 @@
with open(system_qemu_config_path, "r") as config:
with tempfile.NamedTemporaryFile(
prefix="system-qemu-config_", suffix=".txt",
- delete=False) as new_config:
+ delete=False, mode="w") as new_config:
new_config_path = new_config.name
self._RewriteSystemQemuConfig(new_config, config,
get_image)
diff --git a/list/instance_test.py b/list/instance_test.py
index 0789e0d..8b36caf 100644
--- a/list/instance_test.py
+++ b/list/instance_test.py
@@ -22,7 +22,6 @@
import unittest
from unittest import mock
-from six import b
# pylint: disable=import-error
import dateutil.parser
@@ -38,12 +37,12 @@
class InstanceTest(driver_test_lib.BaseDriverTest):
"""Test instance."""
- PS_SSH_TUNNEL = b("/fake_ps_1 --fake arg \n"
- "/fake_ps_2 --fake arg \n"
- "/usr/bin/ssh -i ~/.ssh/acloud_rsa "
- "-o UserKnownHostsFile=/dev/null "
- "-o StrictHostKeyChecking=no -L 54321:127.0.0.1:6520 "
- "-L 12345:127.0.0.1:6444 -N -f -l user 1.1.1.1")
+ PS_SSH_TUNNEL = ("/fake_ps_1 --fake arg \n"
+ "/fake_ps_2 --fake arg \n"
+ "/usr/bin/ssh -i ~/.ssh/acloud_rsa "
+ "-o UserKnownHostsFile=/dev/null "
+ "-o StrictHostKeyChecking=no -L 54321:127.0.0.1:6520 "
+ "-L 12345:127.0.0.1:6444 -N -f -l user 1.1.1.1").encode()
GCE_INSTANCE = {
constants.INS_KEY_NAME: "fake_ins_name",
constants.INS_KEY_CREATETIME: "fake_create_time",