robert.elder commited on
Commit
37f60bf
·
1 Parent(s): a9c1329

trying to make selenium work on pythonanywhere

Browse files
Files changed (1) hide show
  1. ChemID.py +12 -2
ChemID.py CHANGED
@@ -19,7 +19,18 @@ if try_dsstox:
19
  import selenium.webdriver
20
  from selenium.webdriver.chrome.options import Options
21
  from selenium.webdriver.chrome.service import Service
22
- import chromedriver_binary
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  from io import BytesIO
25
  from PIL import ImageOps
@@ -575,7 +586,6 @@ def string2density(name):
575
  url = f'https://comptox.epa.gov/dashboard/chemical/properties/{dtxsid}'
576
  #print(url)
577
  try:
578
- driver_exe = chromedriver_binary.chromedriver_filename
579
  options = Options()
580
  options.add_argument("--headless") # runs in background instead of showing browser window
581
  service = Service(driver_exe)
 
19
  import selenium.webdriver
20
  from selenium.webdriver.chrome.options import Options
21
  from selenium.webdriver.chrome.service import Service
22
+ ## TODO this does not seem very robust
23
+ uname = os.uname()
24
+ if uname.sysname == 'Darwin':
25
+ # my mac
26
+ import chromedriver_binary
27
+ driver_exe = chromedriver_binary.chromedriver_filename
28
+ elif uname.sysname == 'Linux':
29
+ # pythonanywhere
30
+ driver_exe = '/usr/local/bin/chromedriver'
31
+ else:
32
+ import chromedriver_binary
33
+ driver_exe = chromedriver_binary.chromedriver_filename
34
 
35
  from io import BytesIO
36
  from PIL import ImageOps
 
586
  url = f'https://comptox.epa.gov/dashboard/chemical/properties/{dtxsid}'
587
  #print(url)
588
  try:
 
589
  options = Options()
590
  options.add_argument("--headless") # runs in background instead of showing browser window
591
  service = Service(driver_exe)