Last active
August 29, 2015 14:01
-
-
Save rattrayalex/46ac695542fc55b2c681 to your computer and use it in GitHub Desktop.
Gulp Runner
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 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