try/except the import of Tkinter for mac support.
Bug: 113557161
Test: m acloud && acloud on mac
m acloud && acloud on glinux as well to make sure nothing broke (and also scales)
atest acloud_test (make sure you update ~/.bash_profile PATH=/opt/local/bin:$PATH)
Change-Id: I6ce16708483c176e5bac0bb471f7466ad2eb92c2
diff --git a/internal/lib/utils.py b/internal/lib/utils.py
index e537821..8f39455 100755
--- a/internal/lib/utils.py
+++ b/internal/lib/utils.py
@@ -34,7 +34,6 @@
import tarfile
import tempfile
import time
-import Tkinter
import uuid
import zipfile
@@ -65,6 +64,7 @@
_CMD_INSTALL_SSVNC = "sudo apt-get --assume-yes install ssvnc"
_ENV_DISPLAY = "DISPLAY"
_SSVNC_ENV_VARS = {"SSVNC_NO_ENC_WARN": "1", "SSVNC_SCALE": "auto"}
+_DEFAULT_DISPLAY_SCALE = 1.0
_CONFIRM_CONTINUE = ("In order to display the screen to the AVD, we'll need to "
"install a vnc client (ssnvc). \nWould you like acloud to "
@@ -864,13 +864,18 @@
Return:
Float, scale ratio for vnc client.
"""
+ try:
+ import Tkinter
+ # Some python interpreters may not be configured for Tk, just return default scale ratio.
+ except ImportError:
+ return _DEFAULT_DISPLAY_SCALE
root = Tkinter.Tk()
margin = 100 # leave some space on user's monitor.
screen_height = root.winfo_screenheight() - margin
screen_width = root.winfo_screenwidth() - margin
- scale_h = 1
- scale_w = 1
+ scale_h = _DEFAULT_DISPLAY_SCALE
+ scale_w = _DEFAULT_DISPLAY_SCALE
if float(screen_height) < float(avd_height):
scale_h = round(float(screen_height) / float(avd_height), 1)