@@ -193,20 +193,24 @@ def is_zip(url):
193193 return response .status_code == 200 and ('application/zip' in [content_type , meta_content_type ]), response
194194 except :
195195 return False , None
196+
197+ def is_google_chrome_installed ():
198+ import shutil
199+ return shutil .which ("google-chrome" ) is not None
196200
197201def install_chrome (uname ):
202+ if is_google_chrome_installed ():
203+ return
198204 # lsof install as we need it.
199205 install_dependencies = f"""sudo apt install -y python3-pip
200206alias python=python3
201207echo "alias python=python3" >> /home/{ uname } /.bashrc
202- if ! command -v google-chrome &> /dev/null
203- then
204- sudo apt-get update
205- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
206- sudo apt-get install -y lsof wget gnupg2 apt-transport-https ca-certificates software-properties-common adwaita-icon-theme alsa-topology-conf alsa-ucm-conf at-spi2-core dbus-user-session dconf-gsettings-backend dconf-service fontconfig fonts-liberation glib-networking glib-networking-common glib-networking-services gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme libasound2 libasound2-data libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libauthen-sasl-perl libavahi-client3 libavahi-common-data libavahi-common3 libcairo-gobject2 libcairo2 libclone-perl libcolord2 libcups2 libdata-dump-perl libdatrie1 libdconf1 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libencode-locale-perl libepoxy0 libfile-basedir-perl libfile-desktopentry-perl libfile-listing-perl libfile-mimeinfo-perl libfont-afm-perl libfontenc1 libgbm1 libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgraphite2-3 libgtk-3-0 libgtk-3-bin libgtk-3-common libharfbuzz0b libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libice6 libio-html-perl libio-socket-ssl-perl libio-stringy-perl libipc-system-simple-perl libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libllvm11 liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpixman-1-0 libproxy1v5 librest-0.7-0 librsvg2-2 librsvg2-common libsensors-config libsensors5 libsm6 libsoup-gnome2.4-1 libsoup2.4-1 libtext-iconv-perl libthai-data libthai0 libtie-ixhash-perl libtimedate-perl libtry-tiny-perl libu2f-udev liburi-perl libvte-2.91-0 libvte-2.91-common libvulkan1 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwayland-server0 libwww-perl libwww-robotrules-perl libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon0 libxkbfile1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxmu6 libxmuu1 libxrandr2 libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 libz3-4 mesa-vulkan-drivers perl-openssl-defaults shared-mime-info termit x11-common x11-utils xdg-utils xvfb
207- sudo dpkg -i google-chrome-stable_current_amd64.deb
208- rm -rf google-chrome-stable_current_amd64.deb
209- fi
208+
209+ sudo apt-get update
210+ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
211+ sudo apt-get install -y lsof wget gnupg2 apt-transport-https ca-certificates software-properties-common adwaita-icon-theme alsa-topology-conf alsa-ucm-conf at-spi2-core dbus-user-session dconf-gsettings-backend dconf-service fontconfig fonts-liberation glib-networking glib-networking-common glib-networking-services gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme libasound2 libasound2-data libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libauthen-sasl-perl libavahi-client3 libavahi-common-data libavahi-common3 libcairo-gobject2 libcairo2 libclone-perl libcolord2 libcups2 libdata-dump-perl libdatrie1 libdconf1 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libencode-locale-perl libepoxy0 libfile-basedir-perl libfile-desktopentry-perl libfile-listing-perl libfile-mimeinfo-perl libfont-afm-perl libfontenc1 libgbm1 libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgraphite2-3 libgtk-3-0 libgtk-3-bin libgtk-3-common libharfbuzz0b libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libice6 libio-html-perl libio-socket-ssl-perl libio-stringy-perl libipc-system-simple-perl libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libllvm11 liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpixman-1-0 libproxy1v5 librest-0.7-0 librsvg2-2 librsvg2-common libsensors-config libsensors5 libsm6 libsoup-gnome2.4-1 libsoup2.4-1 libtext-iconv-perl libthai-data libthai0 libtie-ixhash-perl libtimedate-perl libtry-tiny-perl libu2f-udev liburi-perl libvte-2.91-0 libvte-2.91-common libvulkan1 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwayland-server0 libwww-perl libwww-robotrules-perl libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon0 libxkbfile1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxmu6 libxmuu1 libxrandr2 libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 libz3-4 mesa-vulkan-drivers perl-openssl-defaults shared-mime-info termit x11-common x11-utils xdg-utils xvfb
212+ sudo dpkg -i google-chrome-stable_current_amd64.deb
213+ rm -rf google-chrome-stable_current_amd64.deb
210214"""
211215 subprocess .run (remove_empty_lines (install_dependencies ), shell = True ,
212216 check = True ,
@@ -489,15 +493,7 @@ def install_desktop_app_in_vm(
489493 api_base_path
490494 ):
491495 # Validate api_base_path
492- api_base_path = os .path .normpath (api_base_path ) if api_base_path else ""
493-
494- if api_base_path == "." :
495- api_base_path = ""
496- elif api_base_path :
497- if not api_base_path .startswith ("/" ):
498- api_base_path = "/" + api_base_path
499- if api_base_path .endswith ("/" ):
500- api_base_path = api_base_path [:- 1 ]
496+ api_base_path = clean_base_path (api_base_path )
501497
502498 # Validate URL
503499 validate_url (debian_installer_url )
@@ -569,6 +565,18 @@ def install_desktop_app_in_vm(
569565 wait_till_desktop_api_up (ip , api_base_path )
570566 click .echo (f"Hurray! your desktop app is up and running. Visit http://{ ip } { api_base_path or '/' } to see the API Docs." )
571567
568+ def clean_base_path (api_base_path ):
569+ api_base_path = os .path .normpath (api_base_path ) if api_base_path else ""
570+
571+ if api_base_path == "." :
572+ api_base_path = ""
573+ elif api_base_path :
574+ if not api_base_path .startswith ("/" ):
575+ api_base_path = "/" + api_base_path
576+ if api_base_path .endswith ("/" ):
577+ api_base_path = api_base_path [:- 1 ]
578+ return api_base_path
579+
572580def delete_installer (default_name ):
573581 if os .path .exists (default_name ):
574582 os .remove (default_name )
@@ -629,7 +637,7 @@ def wait_till_desktop_api_up(ip, api_base_path):
629637 time .sleep (interval )
630638 # If the function hasn't returned after the loop, raise an exception
631639 raise Exception (
632- f"The Desktop Api at http://{ ip } / is not up after { timeout } seconds. Are you sure you have enabled the Api in api-config.ts? "
640+ f"The Desktop Api at http://{ ip } { api_base_path or '/' } is not running. You have surely forgotten to enable the Api in api-config.ts. "
633641 )
634642
635643# python -m bota.vm
0 commit comments