Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
import re
|
| 5 |
from playwright.sync_api import sync_playwright
|
| 6 |
import time
|
| 7 |
-
import os
|
| 8 |
-
import subprocess
|
| 9 |
-
import sys
|
| 10 |
import matplotlib.pyplot as plt
|
| 11 |
from matplotlib.gridspec import GridSpec
|
| 12 |
from windrose import WindroseAxes
|
| 13 |
from datetime import datetime
|
| 14 |
|
|
|
|
| 15 |
# Install Playwright browsers on startup
|
| 16 |
def install_playwright_browsers():
|
| 17 |
try:
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import subprocess
|
| 3 |
+
import sys
|
| 4 |
+
|
| 5 |
+
# Function to install system dependencies
|
| 6 |
+
def install_system_dependencies():
|
| 7 |
+
try:
|
| 8 |
+
# Install apt dependencies
|
| 9 |
+
os.system('apt-get update && apt-get install -y libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libatspi2.0-0 libxcomposite1 libxdamage1')
|
| 10 |
+
return True
|
| 11 |
+
except Exception as e:
|
| 12 |
+
print(f"Error installing system dependencies: {e}")
|
| 13 |
+
return False
|
| 14 |
+
|
| 15 |
+
# Function to install Python packages
|
| 16 |
+
def install_python_packages():
|
| 17 |
+
try:
|
| 18 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "playwright", "windrose"])
|
| 19 |
+
subprocess.check_call([sys.executable, "-m", "playwright", "install", "chromium"])
|
| 20 |
+
subprocess.check_call([sys.executable, "-m", "playwright", "install-deps"])
|
| 21 |
+
return True
|
| 22 |
+
except Exception as e:
|
| 23 |
+
print(f"Error installing Python packages: {e}")
|
| 24 |
+
return False
|
| 25 |
+
|
| 26 |
+
# Install all required dependencies
|
| 27 |
+
print("Installing system dependencies...")
|
| 28 |
+
if not install_system_dependencies():
|
| 29 |
+
print("Warning: Failed to install system dependencies")
|
| 30 |
+
|
| 31 |
+
print("Installing Python packages...")
|
| 32 |
+
if not install_python_packages():
|
| 33 |
+
print("Warning: Failed to install Python packages")
|
| 34 |
+
|
| 35 |
+
# Now import the required packages
|
| 36 |
import gradio as gr
|
| 37 |
import pandas as pd
|
| 38 |
import numpy as np
|
| 39 |
import re
|
| 40 |
from playwright.sync_api import sync_playwright
|
| 41 |
import time
|
|
|
|
|
|
|
|
|
|
| 42 |
import matplotlib.pyplot as plt
|
| 43 |
from matplotlib.gridspec import GridSpec
|
| 44 |
from windrose import WindroseAxes
|
| 45 |
from datetime import datetime
|
| 46 |
|
| 47 |
+
|
| 48 |
# Install Playwright browsers on startup
|
| 49 |
def install_playwright_browsers():
|
| 50 |
try:
|