|
|
@ -105,6 +105,22 @@ Again, after setting the headline status you must: **@FIH PUBLISH**
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return "Invalid command token."
|
|
|
|
return "Invalid command token."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def exec_to_message( cmdline ):
|
|
|
|
|
|
|
|
results = "`" + cmdline + "`:\n\n"
|
|
|
|
|
|
|
|
process = subprocess.Popen( cmdline, shell = True, cwd = app.config[ "STATUS_ROOT" ], stdout = subprocess.PIPE, stderr = subprocess.PIPE )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stdout = strip_progress( strip_ansi( process.stdout.read().decode( 'ascii', 'ignore' ) ) )
|
|
|
|
|
|
|
|
if stdout:
|
|
|
|
|
|
|
|
results += "\n\n```\n" + stdout.replace( "```", "` ` `" ) + "```\n"
|
|
|
|
|
|
|
|
stderr = strip_progress( strip_ansi( process.stderr.read().decode( 'ascii', 'ignore' ) ) )
|
|
|
|
|
|
|
|
if stderr:
|
|
|
|
|
|
|
|
results += "\n\n```\n" + stderr.replace( "```", "` ` `" ) + "```\n"
|
|
|
|
|
|
|
|
if not stdout and not stderr:
|
|
|
|
|
|
|
|
results += '_no output_\n'
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route( '/mattermost/fih', methods = [ 'POST' ] )
|
|
|
|
@app.route( '/mattermost/fih', methods = [ 'POST' ] )
|
|
|
|
def mattermost_fih():
|
|
|
|
def mattermost_fih():
|
|
|
|
# text: @FIH PUBLISH
|
|
|
|
# text: @FIH PUBLISH
|
|
|
@ -124,24 +140,34 @@ def mattermost_fih():
|
|
|
|
cmd = request.form[ 'text' ].strip().split()[ 1 ].upper()
|
|
|
|
cmd = request.form[ 'text' ].strip().split()[ 1 ].upper()
|
|
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ],
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ],
|
|
|
|
'message': "Executing " + cmd + "...",
|
|
|
|
'message': "### Executing `" + cmd + "`...",
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
if cmd == "PUBLISH":
|
|
|
|
if cmd == "PUBLISH":
|
|
|
|
for push_to in app.config[ "GROW_DEPLOY_TO" ]:
|
|
|
|
for pull_from in app.config[ "MERCURIAL_PUSH_TO" ]:
|
|
|
|
cmdline = app.config[ "GROW_BIN" ] + " deploy -f " + push_to
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " pull " + pull_from
|
|
|
|
results = "`" + cmdline + "`:\n\n```\n"
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ],
|
|
|
|
|
|
|
|
'message': message,
|
|
|
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
process = subprocess.Popen( cmdline, shell = True, cwd = app.config[ "STATUS_ROOT" ], stdout = subprocess.PIPE, stderr = subprocess.PIPE )
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " merge"
|
|
|
|
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ],
|
|
|
|
|
|
|
|
'message': message,
|
|
|
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
results += strip_progress( strip_ansi( process.stdout.read().decode( 'ascii', 'ignore' ) ) ).replace( "```", "` ` `" )
|
|
|
|
cmdline = app.config[ "MERCURIAL_BIN" ] + " commit -m 'merge from " + pull_from + "'"
|
|
|
|
results += "```\n"
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
stderr = strip_progress( strip_ansi( process.stderr.read().decode( 'ascii', 'ignore' ) ) )
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ],
|
|
|
|
if stderr:
|
|
|
|
'message': message,
|
|
|
|
results += "\n\n```\n" + stderr.replace( "```", "` ` `" ) + "```\n"
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for deploy_to in app.config[ "GROW_DEPLOY_TO" ]:
|
|
|
|
|
|
|
|
cmdline = app.config[ "GROW_BIN" ] + " deploy -f " + deploy_to
|
|
|
|
|
|
|
|
message = exec_to_message( cmdline )
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ],
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ],
|
|
|
|
'message': results,
|
|
|
|
'message': message,
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
elif cmd == "START":
|
|
|
|
elif cmd == "START":
|
|
|
@ -167,6 +193,10 @@ def mattermost_fih():
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return "WTF command?"
|
|
|
|
return "WTF command?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ],
|
|
|
|
|
|
|
|
'message': "### Finished `" + cmd + "`!",
|
|
|
|
|
|
|
|
} )
|
|
|
|
|
|
|
|
|
|
|
|
return "OK"
|
|
|
|
return "OK"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return "Invalid command token."
|
|
|
|
return "Invalid command token."
|
|
|
|