bluetooth: find servod config path

Remove the hardcodes of python2.7. Find the servod config path
dynamically.

BUG=b:159192174
TEST=Run AVL tests.

Change-Id: I3396468091ad878f0ceee1781ad935bc43451eac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/chameleon/+/2831452
Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Commit-Queue: Shyh-In Hwang <josephsih@chromium.org>
Tested-by: Shyh-In Hwang <josephsih@chromium.org>
diff --git a/chameleond/devices/bluetooth_base_flow.py b/chameleond/devices/bluetooth_base_flow.py
index 107ac69..242f888 100644
--- a/chameleond/devices/bluetooth_base_flow.py
+++ b/chameleond/devices/bluetooth_base_flow.py
@@ -10,6 +10,7 @@
 # TODO: to port chromite.lib.cros_logging to replace legacy logging
 import logging  # pylint: disable=cros-logging-import
 import os
+import re
 
 from . import chameleon_common  # pylint: disable=W0611
 # pylint: disable=C0411
@@ -21,8 +22,6 @@
 class Servod(object):
   """A simple object that performs Servod operations."""
 
-  CONFIG_PATH = '/usr/local/lib64/python2.7/site-packages/servo/data'
-
   # TODO: We had better figure out a way to auto detect the config path to use.
   CONFIG = {
       'kukui': 'krane_rev1.xml',
@@ -36,10 +35,24 @@
     self._start_servod_cmd_list = []
     self._servod = None
     self._measure_power_cmd_list = ['dut-control', 'pp3300_wlan_mw', '-t', '3']
+    self._config_path = self.FindConfigPath()
+
+  def FindConfigPath(self):
+    """Find the path where all servo config files are located.
+
+    The config path is something like
+      /usr/local/lib/python3.6/site-packages/servo/data
+    """
+    for root, _, _ in os.walk('/usr'):
+      if re.search('python3.*servo.*data', root):
+        return root
+
+    logging.error('Failed to find the servod config path.')
+    return ''
 
   def SetBoard(self, board):
     self._board = board
-    self._config = os.path.join(self.CONFIG_PATH, self.CONFIG.get(board, ''))
+    self._config = os.path.join(self._config_path, self.CONFIG.get(board, ''))
 
     if not os.path.isfile(self._config):
       logging.error('The servod config path does not exist: %s', self._config)