Skip to content

Instantly share code, notes, and snippets.

@ddbeck
Created December 2, 2011 05:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ddbeck/1421861 to your computer and use it in GitHub Desktop.
a Coprocess script for iTerm2 to read aloud Fabric task completion
#!/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()
@holyjak
Copy link

holyjak commented Apr 30, 2015

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment