Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
a python script that watches the current directory for changes to ipython notebooks, compiles them to html, and uploads them via scp to a server. an experiment in real-time coding for teaching python to new programmers
import time
from watchdog.observers import Observer
from import FileSystemEventHandler
import envoy
import os
import datetime
class NotebookConverterHandler(FileSystemEventHandler):
def on_modified(self, event):
if event.src_path.endswith('.ipynb'):
# convert to html file'python nbconvert/ --format=html {}'.format(event.src_path))
# convert old file name with ipynb extension to html extension
new_file_name = os.path.splitext(os.path.split(event.src_path)[1])[0] + '.html'
# upload to my site'scp {} name@myawesomeserver'.format(new_file_name))
print 'uploaded {}'.format(
if __name__ == "__main__":
observer = Observer()
observer.schedule(NotebookConverterHandler(), path='.')
while True:
except KeyboardInterrupt:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.