Skip to content

Instantly share code, notes, and snippets.

@ddbeck ddbeck/fabsay.py
Created Dec 2, 2011

Embed
What would you like to do?
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

This comment has been minimized.

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
You can’t perform that action at this time.