OS X 10.10.5에서 launchd를 사용하여 간단한 스크립트를 실행하려고하는데 작업이 실패합니다. 나는 그것이 올바르게 설정되지 않은 권한/권한과 관련이 있다고 생각합니까? launchd 및 Selenium을 사용하여 Python 스크립트가 실행되지 않습니다.
이
는 던졌습니다 오류 코드 :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
내가받을 수 있나요 인쇄 된 내 스크립트에 하드 코딩 한 콘솔 job.out에서 "스크립트를 시작합니다", 그래서 나는 launchd에 실제로 가정 스크립트를 시작하지만 Selenium/Firefox 드라이버에 문제가 있습니까? 그리고 이것이 내 권한 문제가 발생하는 곳입니까?
IDE/실행 및 터미널에서 정상적으로 실행됩니다.
#!/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")
P.List을 다음과 같이 :
<?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>
참고 : 여기에
내가 실행하는 데 노력하고있어 테스트 코드의 정말 launchd에에서 실행하려면이 코드 시간을 변경 나는 시험 할 수있어.
정확하게 맞습니다. 권한이 없으면 스크립트가 제대로 실행되지 않습니다. 나는 또한 귀하의 질문에 launchd에 대한 .plist도 포함시킬 것을 제안합니다. –
의견을 보내 주셔서 감사합니다. 원래 질문에 p.list 코드를 추가했습니다. 사용 권한이 올바르게 설정되지 않은 이유 및/또는 파일을 설정하는 방법/파일이 무엇인지 생각해보십시오. – Kiwi
이것을 launchagent 또는 launchdaemon으로 시작하고 .plist가있는 디렉토리가 있습니까? –