Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ CONTAINER_NAME = os.environ.get("COSMOS_CONTAINER_NAME")
|
|
27 |
# Playwright function for Azure login
|
28 |
def azure_login_with_playwright(username, password):
|
29 |
if not PLAYWRIGHT_INSTALLED:
|
30 |
-
st.error("Playwright is not installed. Please install it using
|
31 |
return False
|
32 |
|
33 |
try:
|
@@ -56,26 +56,21 @@ def azure_login_with_playwright(username, password):
|
|
56 |
st.error(f"An error occurred during browser simulation: {str(e)}")
|
57 |
return False
|
58 |
|
59 |
-
# Function to install Playwright
|
60 |
-
def
|
61 |
try:
|
|
|
62 |
subprocess.run([sys.executable, "-m", "pip", "install", "playwright"],
|
63 |
capture_output=True, text=True, check=True)
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
# Function to install Playwright browsers
|
71 |
-
def install_playwright_browsers():
|
72 |
-
try:
|
73 |
-
result = subprocess.run([sys.executable, "-m", "playwright", "install"],
|
74 |
-
capture_output=True, text=True, check=True)
|
75 |
-
st.success("Playwright browsers installed successfully!")
|
76 |
return True
|
77 |
except subprocess.CalledProcessError as e:
|
78 |
-
st.error(f"Failed to install Playwright
|
79 |
return False
|
80 |
|
81 |
# GitHub configuration
|
@@ -149,11 +144,10 @@ if not st.session_state.logged_in:
|
|
149 |
if login_method == "Manual (Browser Simulation)":
|
150 |
if not PLAYWRIGHT_INSTALLED:
|
151 |
st.warning("Playwright is not installed. Please install it to use browser simulation.")
|
152 |
-
if st.button("Install Playwright"):
|
153 |
-
if
|
154 |
-
|
155 |
-
|
156 |
-
st.stop()
|
157 |
else:
|
158 |
username = st.text_input("Azure Username/Email")
|
159 |
password = st.text_input("Azure Password", type="password")
|
|
|
27 |
# Playwright function for Azure login
|
28 |
def azure_login_with_playwright(username, password):
|
29 |
if not PLAYWRIGHT_INSTALLED:
|
30 |
+
st.error("Playwright is not installed. Please install it using the provided button.")
|
31 |
return False
|
32 |
|
33 |
try:
|
|
|
56 |
st.error(f"An error occurred during browser simulation: {str(e)}")
|
57 |
return False
|
58 |
|
59 |
+
# Function to install Playwright and its dependencies
|
60 |
+
def install_playwright_full():
|
61 |
try:
|
62 |
+
# Install Playwright package
|
63 |
subprocess.run([sys.executable, "-m", "pip", "install", "playwright"],
|
64 |
capture_output=True, text=True, check=True)
|
65 |
+
|
66 |
+
# Install Playwright browsers and dependencies
|
67 |
+
subprocess.run([sys.executable, "-m", "playwright", "install"],
|
68 |
+
capture_output=True, text=True, check=True)
|
69 |
+
|
70 |
+
st.success("Playwright and its dependencies installed successfully!")
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
return True
|
72 |
except subprocess.CalledProcessError as e:
|
73 |
+
st.error(f"Failed to install Playwright or its dependencies. Error: {e.stderr}")
|
74 |
return False
|
75 |
|
76 |
# GitHub configuration
|
|
|
144 |
if login_method == "Manual (Browser Simulation)":
|
145 |
if not PLAYWRIGHT_INSTALLED:
|
146 |
st.warning("Playwright is not installed. Please install it to use browser simulation.")
|
147 |
+
if st.button("Install Playwright and Dependencies"):
|
148 |
+
if install_playwright_full():
|
149 |
+
st.success("Playwright and dependencies installed successfully. Please restart the app.")
|
150 |
+
st.stop()
|
|
|
151 |
else:
|
152 |
username = st.text_input("Azure Username/Email")
|
153 |
password = st.text_input("Azure Password", type="password")
|