Skip to content

Instantly share code, notes, and snippets.

@rattrayalex
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rattrayalex/46ac695542fc55b2c681 to your computer and use it in GitHub Desktop.
Save rattrayalex/46ac695542fc55b2c681 to your computer and use it in GitHub Desktop.
Gulp Runner
#!/usr/bin/env python
import sys
import subprocess
import threading
from clint.textui import puts, colored, indent
def red(msg):
return puts(colored.red(msg, *args, **kwargs))
def cyan(msg, *args, **kwargs):
return puts(colored.cyan(msg, *args, **kwargs))
def beep():
print '\a'
def run_gulp():
while True:
try:
cyan('Starting gulp...')
subprocess.check_call(['gulp'], shell=False)
cyan('strange, gulp completed successfully! Well, goodbye!')
break
except subprocess.CalledProcessError as e:
red('failed: {}'.format(e.returncode))
if e.returncode == 130:
cyan('Exiting for ya =)')
break
else:
beep()
def main():
try:
gulp_thread = threading.Thread(target=run_gulp)
gulp_thread.daemon = False
gulp_thread.start()
while gulp_thread.isAlive():
gulp_thread.join(1)
except (KeyboardInterrupt, SystemExit):
exit()
if __name__ == '__main__':
if 'bin/' not in sys.argv[0]:
red('must be run as bin/deploy.py! from root!')
sys.exit()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment