-
-
Save vsajip/1691174 to your computer and use it in GitHub Desktop.
with selenium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import subprocess | |
import sys | |
from urllib import pathname2url | |
import selenium.webdriver | |
def run(): | |
watch_command = 'inotifywait -rq -e close_write --exclude \'"*.html"\' .'.split() | |
make_command = 'make html'.split() | |
driver = selenium.webdriver.Firefox() | |
path = os.path.join('_build', 'html', 'index.html') | |
url = 'file:///' + pathname2url(os.path.abspath(path)) | |
driver.get(url) | |
while True: | |
# Perhaps should put notifier access in a mutex - not bothering yet | |
notifier = subprocess.Popen(watch_command) | |
notifier.wait() | |
subprocess.call(make_command) | |
driver.refresh() | |
if __name__ == "__main__": | |
if not os.path.isdir('_build'): | |
# very simplistic sanity check. Works for me, as I generally use | |
# sphinx-quickstart defaults | |
print('You must run this application from a Sphinx directory containing _build') | |
rc = 1 | |
else: | |
run() | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment