Created
December 22, 2014 16:33
-
-
Save jefftriplett/9c5d08163dc3f7e0c383 to your computer and use it in GitHub Desktop.
Hubot + Invoke (python)
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
# Description: | |
# Run invoke commands. | |
# | |
# Commands: | |
# hubot invoke <subcommand> | |
{spawn, exec} = require 'child_process' | |
module.exports = (robot) -> | |
# Deploy to staging | |
robot.respond /invoke (.*)/i, (msg) -> | |
send = (text, prefix='') -> | |
msg.send prefix+text | |
# Get subcommand | |
subcommand = msg.match[1] | |
# Tell the user hubot is working on the request | |
msg.send "Preparing to invoke now..." | |
# Execute a pyinvoke command | |
command = "invoke #{subcommand}" | |
invoke = exec command #, (err, stdout, stderr) -> | |
invoke.stderr.on 'data', (data) -> | |
for line in data.toString().split('\n') | |
send line, 'Error: ' | |
invoke.stdout.on 'data', (data) -> | |
for line in data.toString().split('\n') | |
send line | |
invoke.on 'exit', (code) -> | |
if code == 0 | |
send "Done #{command}." | |
else | |
send "FAILED #{command}. Returned #{code}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment