mirror of
https://github.com/nextcloud/docker.git
synced 2025-03-15 19:05:09 +01:00
Made install script work with Firefox and wrapped for errors
This commit is contained in:
parent
88600d6f53
commit
9a9b0f85df
1 changed files with 41 additions and 25 deletions
|
@ -1,41 +1,57 @@
|
||||||
|
import sys
|
||||||
from time import time_ns
|
from time import time_ns
|
||||||
|
|
||||||
from playwright.sync_api import sync_playwright
|
from playwright.sync_api import sync_playwright, Error
|
||||||
|
|
||||||
def log_note(message: str) -> None:
|
def log_note(message: str) -> None:
|
||||||
timestamp = str(time_ns())[:16]
|
timestamp = str(time_ns())[:16]
|
||||||
print(f"{timestamp} {message}")
|
print(f"{timestamp} {message}")
|
||||||
|
|
||||||
def main():
|
def main(browser_name: str = "chromium"):
|
||||||
with sync_playwright() as playwright:
|
with sync_playwright() as playwright:
|
||||||
log_note("Launch browser")
|
log_note(f"Launch browser {browser_name}")
|
||||||
browser_type = playwright.chromium
|
if browser_name == "firefox":
|
||||||
browser = browser_type.launch(
|
browser_type = playwright.firefox
|
||||||
headless=True,
|
else:
|
||||||
args=["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"]
|
browser_type = playwright.chromium
|
||||||
)
|
browser = browser_type.launch(headless=True)
|
||||||
page = browser.new_page()
|
context = browser.new_context()
|
||||||
page.goto('http://nc/')
|
page = context.new_page()
|
||||||
page.set_default_timeout(180_000)
|
try:
|
||||||
|
page.goto('http://nc/')
|
||||||
|
page.set_default_timeout(180_000)
|
||||||
|
|
||||||
# 1. Create User
|
# 1. Create User
|
||||||
log_note("Create admin user")
|
log_note("Create admin user")
|
||||||
page.type('#adminlogin', 'Crash')
|
page.type('#adminlogin', 'Crash')
|
||||||
page.type('#adminpass', 'Override')
|
page.type('#adminpass', 'Override')
|
||||||
page.click('.primary')
|
page.click('.primary')
|
||||||
|
|
||||||
# 2. Install all Apps
|
# 2. Install all Apps
|
||||||
log_note("Install recommended apps")
|
log_note("Install recommended apps")
|
||||||
install_selector = '.button-vue--vue-primary'
|
install_selector = '.button-vue--vue-primary'
|
||||||
page.wait_for_selector(install_selector)
|
page.wait_for_selector(install_selector)
|
||||||
page.click(install_selector)
|
page.click(install_selector)
|
||||||
|
|
||||||
# 3. Dashboard
|
# 3. Dashboard
|
||||||
page.wait_for_selector('.app-dashboard')
|
page.wait_for_selector('.app-dashboard')
|
||||||
log_note("Installation complete")
|
log_note("Installation complete")
|
||||||
|
|
||||||
|
except Error as e:
|
||||||
|
log_note(f"Exception occurred: {e.message}")
|
||||||
|
log_note(f"Page content was: {page.content()}")
|
||||||
|
raise e
|
||||||
|
|
||||||
browser.close()
|
browser.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
if len(sys.argv) > 1:
|
||||||
|
browser_name = sys.argv[1].lower()
|
||||||
|
if browser_name not in ["chromium", "firefox"]:
|
||||||
|
print("Invalid browser name. Please choose either 'chromium' or 'firefox'.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
browser_name = "chromium"
|
||||||
|
|
||||||
|
main(browser_name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue