Skip to content

Instantly share code, notes, and snippets.

@rattrayalex
Last active Aug 29, 2015
Embed
What would you like to do?
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