acloud: fix py3 3rd_party compatible issues: ModuleNotFoundError: No module named 'http.client'

1 do sys.path.insert(0, /usr/lib/python3.X) while running in python3.
2 pyopenssl doesn't work in python3, so move into version py2.
3 replace import httplib as import six.moves.http_client.

BUG: 137195528
BUG: 144743252
Test: acloud-dev create
acloud-dev create --local-instance
acloud-dev create --local-instance --local-image
acloud-dev create --local-image

Change-Id: I5237da4a46fb7af43bfe4f3006a690de08b628b5
diff --git a/Android.bp b/Android.bp
index b211ee7..0e9b215 100644
--- a/Android.bp
+++ b/Android.bp
@@ -19,6 +19,9 @@
         py2: {
             enabled: true,
             embedded_launcher: false,
+            libs: [
+                "py-pyopenssl",
+            ]
         },
         py3: {
             enabled: false,
@@ -56,7 +59,6 @@
         "py-dateutil",
         "py-google-api-python-client",
         "py-oauth2client",
-        "py-pyopenssl",
         "py-six",
     ],
     dist: {
diff --git a/acloud_test.py b/acloud_test.py
index a7fc680..ce59496 100644
--- a/acloud_test.py
+++ b/acloud_test.py
@@ -19,6 +19,7 @@
 import logging
 import os
 import sys
+import sysconfig
 import unittest
 
 
@@ -36,6 +37,9 @@
 logger.setLevel(logging.CRITICAL)
 logger.addHandler(logging.FileHandler("/dev/null"))
 
+if sys.version_info.major == 3:
+    sys.path.insert(0, os.path.dirname(sysconfig.get_paths()['purelib']))
+
 
 def GetTestModules():
     """Return list of testable modules.
diff --git a/internal/lib/base_cloud_client.py b/internal/lib/base_cloud_client.py
index f45d74c..b4167c5 100755
--- a/internal/lib/base_cloud_client.py
+++ b/internal/lib/base_cloud_client.py
@@ -17,17 +17,17 @@
 
 BasicCloudApiCliend does basic setup for a cloud API.
 """
-import httplib
 import logging
 import socket
 import ssl
 
 import six
+from six.moves import http_client
 
 # pylint: disable=import-error
+import httplib2
 from apiclient import errors as gerrors
 from apiclient.discovery import build
-import httplib2
 from oauth2client import client
 
 from acloud import errors
@@ -57,7 +57,7 @@
         502,  # Bad Gateway
         503,  # Service Unavailable
     ]
-    RETRIABLE_ERRORS = (httplib.HTTPException, httplib2.HttpLib2Error,
+    RETRIABLE_ERRORS = (http_client.HTTPException, httplib2.HttpLib2Error,
                         socket.error, ssl.SSLError)
     RETRIABLE_AUTH_ERRORS = (client.AccessTokenRefreshError, )
 
diff --git a/public/acloud_main.py b/public/acloud_main.py
index b26a01e..ac63029 100644
--- a/public/acloud_main.py
+++ b/public/acloud_main.py
@@ -70,8 +70,10 @@
 from __future__ import print_function
 import argparse
 import logging
+import os
 import platform
 import sys
+import sysconfig
 import traceback
 
 # TODO: Remove this once we switch over to embedded launcher.
@@ -93,6 +95,12 @@
         print("  - or -")
         print("  POSIXLY_CORRECT=1 port -N install python27")
     sys.exit(1)
+# This is a workaround to put '/usr/lib/python3.X' ahead of googleapiclient of
+# build system path list to fix python3 issue of http.client(b/144743252)
+# that googleapiclient existed http.py conflict with python3 build-in lib.
+# Using embedded_launcher(b/135639220) perhaps work whereas it didn't solve yet.
+if sys.version_info.major == 3:
+    sys.path.insert(0, os.path.dirname(sysconfig.get_paths()['purelib']))
 
 # By Default silence root logger's stream handler since 3p lib may initial
 # root logger no matter what level we're using. The acloud logger behavior will