enesmanan commited on
Commit
a258a12
·
verified ·
1 Parent(s): 66f5d71

hadi artıkkkk

Browse files
Files changed (3) hide show
  1. app.py +21 -36
  2. packages.txt +3 -1
  3. requirements.txt +1 -1
app.py CHANGED
@@ -7,6 +7,9 @@ import plotly.graph_objects as go
7
  import os
8
  import subprocess
9
  import logging
 
 
 
10
 
11
  # Logging ayarları
12
  logging.basicConfig(level=logging.INFO)
@@ -15,46 +18,28 @@ logger = logging.getLogger(__name__)
15
  def setup_chrome():
16
  """Chrome ve ChromeDriver kurulumu"""
17
  try:
18
- # Chrome kurulumu komutları
19
- commands = [
20
- 'apt-get update',
21
- 'apt-get install -y wget unzip',
22
- 'wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -',
23
- 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list',
24
- 'apt-get update',
25
- 'apt-get install -y google-chrome-stable'
26
- ]
27
 
28
- for cmd in commands:
29
- logger.info(f"Executing: {cmd}")
30
- result = os.system(cmd)
31
- if result != 0:
32
- logger.error(f"Command failed: {cmd}")
33
- raise Exception(f"Command failed: {cmd}")
34
 
35
- # ChromeDriver kurulumu
36
- chrome_version = subprocess.check_output(['google-chrome', '--version']).decode().strip().split()[2].split('.')[0]
37
- logger.info(f"Detected Chrome version: {chrome_version}")
38
-
39
- driver_commands = [
40
- f'wget -q "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_{chrome_version}" -O chrome_version',
41
- f'wget -q "https://chromedriver.storage.googleapis.com/$(cat chrome_version)/chromedriver_linux64.zip"',
42
- 'unzip chromedriver_linux64.zip',
43
- 'mv chromedriver /usr/local/bin/',
44
- 'chmod +x /usr/local/bin/chromedriver'
45
- ]
46
-
47
- for cmd in driver_commands:
48
- logger.info(f"Executing: {cmd}")
49
- result = os.system(cmd)
50
- if result != 0:
51
- logger.error(f"Command failed: {cmd}")
52
- raise Exception(f"Command failed: {cmd}")
53
-
54
- logger.info("Chrome ve ChromeDriver başarıyla kuruldu!")
55
 
 
 
 
 
 
 
56
  except Exception as e:
57
- logger.error(f"Chrome kurulumunda hata: {str(e)}")
58
  raise
59
 
60
  class ReviewAnalysisApp:
 
7
  import os
8
  import subprocess
9
  import logging
10
+ from selenium import webdriver
11
+ from selenium.webdriver.chrome.options import Options
12
+ from selenium.webdriver.chrome.service import Service
13
 
14
  # Logging ayarları
15
  logging.basicConfig(level=logging.INFO)
 
18
  def setup_chrome():
19
  """Chrome ve ChromeDriver kurulumu"""
20
  try:
21
+ # Chromium kullanarak Chrome yerine (Hugging Face'de önceden yüklü)
22
+ chrome_options = webdriver.ChromeOptions()
23
+ chrome_options.add_argument('--headless')
24
+ chrome_options.add_argument('--no-sandbox')
25
+ chrome_options.add_argument('--disable-dev-shm-usage')
26
+ chrome_options.binary_location = '/usr/bin/chromium' # Chromium path
 
 
 
27
 
28
+ # ChromeDriver'ı webdriver-manager ile yönet
29
+ from webdriver_manager.chrome import ChromeDriverManager
30
+ from webdriver_manager.core.utils import ChromeType
 
 
 
31
 
32
+ driver_path = ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()
33
+ logger.info(f"ChromeDriver path: {driver_path}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ # Test et
36
+ service = Service(driver_path)
37
+ with webdriver.Chrome(service=service, options=chrome_options) as driver:
38
+ driver.get("https://www.google.com")
39
+ logger.info("Chrome test başarılı!")
40
+
41
  except Exception as e:
42
+ logger.error(f"Chrome kurulumunda hata: {str(e)}", exc_info=True)
43
  raise
44
 
45
  class ReviewAnalysisApp:
packages.txt CHANGED
@@ -1,2 +1,4 @@
1
  chromium
2
- chromium-driver
 
 
 
1
  chromium
2
+ chromium-driver
3
+ wget
4
+ unzip
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
  pandas
2
- numpy
3
  seaborn
4
  matplotlib
5
  torch==2.1.2
 
1
  pandas
2
+ numpy==1.24.3
3
  seaborn
4
  matplotlib
5
  torch==2.1.2