Created
December 2, 2011 05:08
-
-
Save ddbeck/1421861 to your computer and use it in GitHub Desktop.
a Coprocess script for iTerm2 to read aloud Fabric task completion
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/local/bin/python2.7 | |
# use as a trigger. | |
# Trigger regex: Executing task '(.*)'$ | |
# Coprocess command: $HOME/bin/fabsay.py \1 | |
import subprocess | |
import sys | |
def incoming(): | |
while True: | |
yield raw_input() | |
def say(phrase): | |
subprocess.call(['say', phrase]) | |
def main(): | |
task_name = sys.argv[1] | |
say('Starting {}'.format(task_name)) | |
for line in incoming(): | |
if 'Done.' in line: | |
say('{} finished.'.format(task_name)) | |
sys.exit(0) | |
if 'Aborting.' in line: | |
say('{} failed.'.format(task_name)) | |
sys.exit(1) | |
if 'Executing task' in line and task_name not in line: | |
say('{} finished.'.format(task_name)) | |
task_name = line[ | |
line.index("Executing task") + len("Executing task") + 1: | |
-1 | |
] | |
say('Starting {}'.format(task_name)) | |
if 'Stopped.' in line: | |
sys.exit(0) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot, this was very useful when creating my Coprocess "iTerm coprocess reporting result of (Mocha) tests run via nodemon". I could not have done this without you!