Skip to content

Commit f665ae2

Browse files
committed
added docs
1 parent 3cbbca7 commit f665ae2

File tree

59 files changed

+3589
-732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3589
-732
lines changed

bota/setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
install_requires = [
77
"click",
8-
"pytweening",
98
]
109

1110

@@ -54,7 +53,7 @@ def get_description():
5453
#
5554
# This field corresponds to the "Description" metadata field:
5655
# https://packaging.python.org/specifications/core-metadata/#description-optional
57-
version='4.0.150',
56+
version='4.0.152',
5857
author="Chetan Jain",
5958
author_email="[email protected]",
6059
description="CLI for botasaurus.",

bota/src/bota/vm.py

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -785,21 +785,49 @@ def validate_url(url):
785785
except requests.exceptions.RequestException as e2:
786786
raise Exception(f"The URL {url} does not point to a valid Debian installer.")
787787

788+
def api_config_disabled(service_name, seconds):
789+
"""
790+
Checks if the API is disabled by looking for specific error messages in service logs.
791+
792+
Args:
793+
service_name (str): Name of the systemd service
794+
795+
Returns:
796+
bool: True if API is disabled, False otherwise
797+
"""
798+
try:
799+
logs = subprocess.check_output(
800+
f"sudo journalctl -u {service_name} --since '{seconds} seconds ago'",
801+
shell=True, text=True
802+
)
803+
return "Kindly enable the API in" in logs
804+
except subprocess.CalledProcessError:
805+
return False
806+
def generate_api_not_enabled_message():
807+
return f"""The API is not enabled in "api-config.ts".
808+
To enable it:
809+
1. Follow the instructions at:
810+
https://www.omkar.cloud/botasaurus/docs/botasurus-desktop/botasaurus-desktop-api/adding-api#how-to-add-an-api-to-your-app
811+
2. Once enabled, rebuild and reinstall the app in your VM."""
812+
788813
def wait_till_desktop_api_up(ip, api_base_path, package_service_name):
789814
"""
790-
Polls the given IP address every 10 seconds for 180 seconds to check if it's up.
815+
Polls the given IP address every second for 30 seconds to check if it's up.
816+
Checks for API configuration issues after 12 seconds.
791817
792818
Args:
793819
ip (str): The IP address to check.
794820
api_base_path (str): The API path prefix.
795821
package_service_name (str): The name of the service package.
796822
797823
Raises:
798-
Exception: If the IP is not up after 180 seconds.
824+
Exception: If the IP is not up after 30 seconds.
799825
"""
800826
timeout = 30 # Total time to wait in seconds
801827
interval = 1 # Time to wait between checks in seconds
802828
end_time = time.time() + timeout
829+
api_config_check_time = 10 # Check for API config issues after 10 seconds
830+
api_config_checked = False
803831

804832
while time.time() < end_time:
805833
try:
@@ -816,20 +844,27 @@ def wait_till_desktop_api_up(ip, api_base_path, package_service_name):
816844
# If a connection error occurs, just wait and try again
817845
pass
818846

847+
# Check for API configuration issues after 12 seconds
848+
elapsed_time = timeout - (end_time - time.time())
849+
if elapsed_time >= api_config_check_time and not api_config_checked:
850+
if api_config_disabled(package_service_name, api_config_check_time + 5):
851+
raise Exception(generate_api_not_enabled_message())
852+
api_config_checked = True
853+
819854
time.sleep(interval)
820855

821-
# If the function hasn't returned after the loop, raise an exception
856+
# After timeout, check if it's an API configuration issue
822857
api_url = f"http://{ip}{api_base_path or '/'}"
823-
error_message = f"""
824-
The Desktop API at {api_url} is not running. This may be because:
825-
826-
1. You have forgotten to enable the API in "api-config.ts".
827-
If so, kindly enable it in "api-config.ts".
858+
859+
if api_config_disabled(package_service_name, timeout + 5):
860+
error_message = generate_api_not_enabled_message()
861+
else:
862+
error_message = f"""The Desktop API at {api_url} is not running.
828863
829-
2. The service failed to start due to a startup error.
830-
Kindly check logs by running: journalctl -u {package_service_name} -b
831-
"""
832-
raise Exception(error_message.strip())
864+
To troubleshoot, view the logs by running:
865+
journalctl -u {package_service_name} -b"""
866+
867+
raise Exception(error_message)
833868

834869
def uninstall_desktop_app_in_vm(debian_installer_url, package_name, skip_apache_request_routing):
835870
"""

0 commit comments

Comments
 (0)