Skip to content

Instantly share code, notes, and snippets.

@firefightingcode
Created April 4, 2014 12:04
Show Gist options
  • Save firefightingcode/9973215 to your computer and use it in GitHub Desktop.
Save firefightingcode/9973215 to your computer and use it in GitHub Desktop.
This little script watches for changes made to the source files of your Pebble project and automatically builds and installs the app or watchface to your smartphone.
import sys
import time
from subprocess import call
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
class ChangeHandler(PatternMatchingEventHandler):
patterns = ["*.c", "*.h", "*.json"]
def on_any_event(self, event):
if not event.is_directory and "/build/" not in event.src_path:
build_success = call(["pebble", "build"])
if build_success == 0:
call(["pebble", "install", "--phone", sys.argv[1]])
if __name__ == '__main__':
if len(sys.argv) <= 1:
print 'usage: ' + sys.argv[0] + " ip_address_for_pebble"
sys.exit(1)
observer = Observer()
observer.schedule(ChangeHandler(), '.', recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment