I'm trying to run a simple script using launchd in OS X 10.10.5 but the job fails. I think it has something to do with permissions/privileges not set correctly?
This is the error code it throws up:
Traceback (most recent call last): File "/Users/John/Documents/AutoRun/OpenTwitter.py", line 7, in driver = webdriver.Firefox() File "/Library/Python/2.7/site-packages/selenium-3.0.0.b2-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 64, in init self.service = Service(executable_path, firefox_binary=self.options.binary_location) File "/Library/Python/2.7/site-packages/selenium-3.0.0.b2-py2.7.egg/selenium/webdriver/firefox/service.py", line 44, in init log_file = open(log_path, "a+") IOError: [Errno 13] Permission denied: 'geckodriver.log' Exception AttributeError: "'Service' object has no attribute 'log_file'" in
<bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x10ca6bdd0>>ignored
I do get the printed "start script" in the console job.out that I've hardcoded into my script, so I assume launchd is actually starting the script ok, but it's running into a problem with Selenium/Firefox driver? And this is where my permissions issue is coming into play?
It runs fine in IDE/run and from the terminal.
Here's the test code I'm trying to run:
#!/usr/bin/python
from selenium import webdriver
print("start script")
driver = webdriver.Firefox()
driver.get("https://twitter.com/search?q=news&src=typd&lang=en")
print("twitter open, done")
The P.List as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>JohnsJob.job</string>
<key>Program</key>
<string>/Users/John/Documents/AutoRun/OpenTwitter.py</string>
<key>StandardErrorPath</key>
<string>/tmp/JohnsJob.job.err</string>
<key>StandardOutPath</key>
<string>/tmp/JohnsJob.job.out</string>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>10</integer>
<key>Minute</key>
<integer>14</integer>
<key>Weekday</key>
<integer>3</integer>
</dict>
</array>
</dict>
</plist>
Note: I change the time for this code to run in launchd so I can test.
<key>Program</key><string>/Users/John/Documents/AutoRun/OpenTwitter.py</string>to<key>ProgramArguments</key> <array> <string>python</string> <string>/Users/John/Documents/AutoRun/OpenTwitter.py</string> </array>