Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,25 @@
|
|
1 |
import streamlit as st
|
2 |
# Must be the first Streamlit command
|
3 |
st.set_page_config(page_title="Advanced File Downloader", layout="wide")
|
|
|
4 |
import os
|
5 |
import subprocess
|
6 |
|
7 |
-
# Playwright dependency installation
|
8 |
def install_playwright_dependencies():
|
9 |
try:
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
dependencies = [
|
12 |
'libnss3',
|
13 |
'libnspr4',
|
@@ -18,16 +30,28 @@ def install_playwright_dependencies():
|
|
18 |
'libxdamage1',
|
19 |
'libatspi2.0-0'
|
20 |
]
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
subprocess.run(['playwright', 'install'], check=True)
|
23 |
-
|
|
|
24 |
except subprocess.CalledProcessError as e:
|
25 |
st.error(f"Error installing dependencies: {e}")
|
|
|
|
|
|
|
|
|
26 |
except Exception as e:
|
27 |
st.error(f"Unexpected error: {e}")
|
28 |
|
29 |
# Call the installation function
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
import os
|
33 |
import subprocess
|
|
|
1 |
import streamlit as st
|
2 |
# Must be the first Streamlit command
|
3 |
st.set_page_config(page_title="Advanced File Downloader", layout="wide")
|
4 |
+
|
5 |
import os
|
6 |
import subprocess
|
7 |
|
|
|
8 |
def install_playwright_dependencies():
|
9 |
try:
|
10 |
+
# First method: using playwright install-deps
|
11 |
+
try:
|
12 |
+
subprocess.run(['sudo', 'playwright', 'install-deps'], check=True)
|
13 |
+
st.success("Successfully installed Playwright dependencies using playwright install-deps")
|
14 |
+
return
|
15 |
+
except subprocess.CalledProcessError:
|
16 |
+
st.warning("Failed to install using playwright install-deps, trying apt-get method...")
|
17 |
+
|
18 |
+
# Second method: using apt-get
|
19 |
+
# Update package list
|
20 |
+
subprocess.run(['sudo', 'apt-get', 'update', '-y'], check=True)
|
21 |
+
|
22 |
+
# Install required dependencies
|
23 |
dependencies = [
|
24 |
'libnss3',
|
25 |
'libnspr4',
|
|
|
30 |
'libxdamage1',
|
31 |
'libatspi2.0-0'
|
32 |
]
|
33 |
+
|
34 |
+
install_command = ['sudo', 'apt-get', 'install', '-y'] + dependencies
|
35 |
+
subprocess.run(install_command, check=True)
|
36 |
+
|
37 |
+
# Install playwright browsers
|
38 |
subprocess.run(['playwright', 'install'], check=True)
|
39 |
+
|
40 |
+
st.success("Successfully installed Playwright dependencies using apt-get")
|
41 |
except subprocess.CalledProcessError as e:
|
42 |
st.error(f"Error installing dependencies: {e}")
|
43 |
+
st.error("Please run the following commands manually:")
|
44 |
+
st.code("sudo apt-get update")
|
45 |
+
st.code("sudo apt-get install -y libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxcomposite1 libxdamage1 libatspi2.0-0")
|
46 |
+
st.code("playwright install")
|
47 |
except Exception as e:
|
48 |
st.error(f"Unexpected error: {e}")
|
49 |
|
50 |
# Call the installation function
|
51 |
+
with st.spinner("Installing Playwright dependencies..."):
|
52 |
+
install_playwright_dependencies()
|
53 |
+
|
54 |
+
# Rest of your code...
|
55 |
|
56 |
import os
|
57 |
import subprocess
|