[Autotest] server/hosts/ py3 migration (Compatible with py2)

Converting the /hosts/ dir to be compatible with both python 2 and
python 3. This was checked with the tool "2to3" along with using AST to
verify there is incompatible syntax.

TEST=dummy_Pass, python3 -m py_compile, applicable unittests(py2 only)
BUG=chromium:990593

Change-Id: Idf0fcaeec8930c7cbadd082a5a9502e68895a597
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2314839
Tested-by: Derek Beckett <dbeckett@chromium.org>
Commit-Queue: Gregory Nisbet <gregorynisbet@google.com>
Reviewed-by: Greg Edelston <gredelston@google.com>
diff --git a/server/hosts/servo_host.py b/server/hosts/servo_host.py
index efcfccd..c79ab05 100644
--- a/server/hosts/servo_host.py
+++ b/server/hosts/servo_host.py
@@ -1,3 +1,4 @@
+# Lint as: python2, python3
 # Copyright (c) 2013 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.
@@ -9,6 +10,10 @@
 """This file provides core logic for servo verify/repair process."""
 
 
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
 import logging
 import os
 import re
@@ -16,7 +21,8 @@
 import threading
 import json
 import time
-import xmlrpclib
+import six
+import six.moves.xmlrpc_client
 import calendar
 
 from autotest_lib.client.bin import utils
@@ -196,11 +202,11 @@
         self.remote_log_dir = '%s_%s' % (self.SERVOD_LOG_PREFIX,
                                          self.servo_port)
         # Path of the servo host lock file.
-        self._lock_file = (self.TEMP_FILE_DIR + str(self.servo_port)
-                           + self.LOCK_FILE_POSTFIX)
+        self._lock_file = (self.TEMP_FILE_DIR + str(self.servo_port) +
+                           self.LOCK_FILE_POSTFIX)
         # File path to declare a reboot request.
-        self._reboot_file = (self.TEMP_FILE_DIR + str(self.servo_port)
-                             + self.REBOOT_FILE_POSTFIX)
+        self._reboot_file = (self.TEMP_FILE_DIR + str(self.servo_port) +
+                             self.REBOOT_FILE_POSTFIX)
 
         # Lock the servo host if it's an in-lab labstation to prevent other
         # task to reboot it until current task completes. We also wait and
@@ -304,7 +310,7 @@
             # own separate proxy connection.
             if not hasattr(self._local, "_per_thread_proxy"):
                 remote = 'http://%s:%s' % (self.hostname, self.servo_port)
-                self._local._per_thread_proxy = xmlrpclib.ServerProxy(remote)
+                self._local._per_thread_proxy = six.moves.xmlrpc_client.ServerProxy(remote)
             return self._local._per_thread_proxy
 
 
@@ -1516,7 +1522,7 @@
     @return `servo_args` dict with host and an optional port.
     """
     info = dut_host.host_info_store.get()
-    servo_args = {k: v for k, v in info.attributes.iteritems()
+    servo_args = {k: v for k, v in six.iteritems(info.attributes)
                   if k in servo_constants.SERVO_ATTR_KEYS}
 
     if servo_constants.SERVO_PORT_ATTR in servo_args: