toolchain-utils: Partially port scripts to python 3

This patch ports some still-in-use python scripts under root directory
of toolchain-utils to python 3.

BUG=chromium:1011676
TEST=Passed unittests and tested with manually launching.

Change-Id: Id6066944780a7204fe4746cd271f41ac20f2274d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2049103
Commit-Queue: Zhizhou Yang <zhizhouy@google.com>
Tested-by: Zhizhou Yang <zhizhouy@google.com>
Auto-Submit: Zhizhou Yang <zhizhouy@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
diff --git a/build_tc.py b/build_tc.py
index c14b690..9b90f55 100755
--- a/build_tc.py
+++ b/build_tc.py
@@ -1,8 +1,9 @@
-#!/usr/bin/env python2
-#
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
 # Copyright 2010 The Chromium OS Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
+
 """Script to build the ChromeOS toolchain.
 
 This script sets up the toolchain if you give it the gcctools directory.
@@ -100,8 +101,9 @@
     command = 'mkdir -p %s' % build_dir
     self._ce.RunCommand(command)
 
-    mounted_build_dir = os.path.join(self._chromeos_root, 'chroot', '%s-%s' %
-                                     (self._chroot_source_path, build_suffix))
+    mounted_build_dir = os.path.join(
+        self._chromeos_root, 'chroot',
+        '%s-%s' % (self._chroot_source_path, build_suffix))
     build_mp = tc_enter_chroot.MountPoint(build_dir, mounted_build_dir,
                                           getpass.getuser())
     mount_points.append(build_mp)
@@ -148,10 +150,10 @@
     if self._name == 'gcc' and not self._gcc_enable_ccache:
       env['USE'] += ' -wrapper_ccache'
 
-    env['%s_SOURCE_PATH' % self._name.upper()] = (os.path.join(
-        '/', self._chroot_source_path))
+    env['%s_SOURCE_PATH' % self._name.upper()] = (
+        os.path.join('/', self._chroot_source_path))
     env['ACCEPT_KEYWORDS'] = '~*'
-    env_string = ' '.join(["%s=\"%s\"" % var for var in env.items()])
+    env_string = ' '.join(['%s="%s"' % var for var in env.items()])
     command = 'emerge =cross-%s/%s-9999' % (self._ctarget, self._name)
     full_command = 'sudo %s %s' % (env_string, command)
     rv = self._ce.ChrootRunCommand(self._chromeos_root, full_command)