modifikasi skrip berikut * menggunakan ‘selenium/standalone-chrome’ * port 4444…
- User
modifikasi skrip berikut
- menggunakan ‘selenium/standalone-chrome’
- port 4444
#@markdown Firefox Browser
#@markdown Firefox download directory =
CONFIG_DIRECTORY/downloadsimport os import urllib.request from IPython.display import clear_output, HTML, display import subprocess import time
##################################### TYPE = "firefox-esr" # @param ["firefox", "firefox-esr"] CONFIG_DIRECTORY = "/content/tools/firefox" # @param {type:"string"} HOME = os.path.expanduser("~")
def in_output(command, output): try: result = subprocess.run(command.split(), capture_output=True, text=True, check=True) return output in result.stdout except subprocess.CalledProcessError: return False
def check_log_until_line_appears(command, line_to_check): process = subprocess.Popen(command, stdout=subprocess.PIPE) while True: line = process.stdout.readline().decode('utf-8') if line_to_check in line: return True elif line == '': return False else: time.sleep(0.1)
def popen(cmd, description=None): try: if description: clear_output() print(description) subprocess.Popen(cmd.split()).wait() except subprocess.CalledProcessError as e: print(f"Error running command: {cmd}") print(f"Error message: {e}") raise
def run_command_background(cmd): subprocess.Popen(cmd.split())
print("Loading environment…") os.makedirs(CONFIG_DIRECTORY, exist_ok=True)
Install udocker
if not os.path.exists("/usr/local/bin/udocker"): popen('pip install udocker', "Installing udocker …") popen('udocker --allow-root install', 'Setting up udocker …')
Download image jlesage/firefox
if not in_output('udocker --allow-root images', f'jlesage/{TYPE}:latest'): popen(f'udocker --allow-root pull jlesage/{TYPE}', f"Pulling jlesage/{TYPE} image …")
Create and name the container
if not in_output('udocker --allow-root ps', TYPE): popen(f'udocker --allow-root create --name={TYPE} jlesage/{TYPE}', f"Creating {TYPE} container …")
Run the container
command = f'udocker --allow-root run -v {CONFIG_DIRECTORY}:/config -p 5800:5800 {TYPE}'.split() line_to_check = '[supervisor ] all services started.'
print("Starting the container…") done = check_log_until_line_appears(command, line_to_check)
Port forwarding with Cloudflare tunnel (Quick Tunnel)
clear_output() if done: print("All services started.")
!nohup cloudflared tunnel --no-autoupdate --metrics localhost:58000 --url localhost:5800 > /dev/null 2>&1 & time.sleep(5) !curl -s http://localhost:58000/quicktunnel | jq -r '.hostname' > hosttunnel from IPython.display import clear_output clear_output() with open('hosttunnel', 'r') as file: host = file.read() !rm hosttunnel link_html = '<a href="http://{}/" target="_blank">{}</a>'.format(host, host) display(HTML(link_html)) - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.