def deploy_demo(branch=None): """ Runs the demo task for the specified branch """ result_key = str(int(time.time())) # don't deploy these branches ignored_branches = ['dev', 'staging', 'production'] # hack to check to make sure a demo of that branch exists hook_key = 'github' ops.run_fabric_task('demo:amara show_demos', result_key=hook_key, notify=False) demos = ops.get_fabric_log(hook_key) demo_name = branch.replace('-', '_') if branch not in ignored_branches and demos.find(demo_name) != -1: task = 'demo:amara,{0} deploy'.format(branch) job = queue_task(ops.run_fabric_task, task, result_key)
def index(): workflows = config.get_workflows() job = None result_key = None workflow_id = None workflows = utils.sorted_dict(workflows, 'name') if request.method == 'POST': form = request.form workflow_id = form.get('workflow_id') if workflow_id: workflow = [x for x in workflows if x.get('name') == workflow_id][0] username = session.get('user', {}).get('username') db.log({ 'ip': request.remote_addr, 'user': username, 'command': 'Workflow: {0}'.format(workflow_id), }) args = workflow.get('arguments') # substitute args task = workflow.get('command') if args: for a in args: arg_name = a.get('name') arg_val = form.get(arg_name, None) task = task.replace('<{0}>'.format(arg_name), form.get(arg_name)) # add proxy_user to get launchpad user task = task.replace('<proxy_user>', username) # generate result_key result_key = str(int(time.time())) # run command job = queue_task(ops.run_fabric_task, task, result_key, workflow.get('notify')) ctx = { 'workflows': workflows, 'job': job, 'result_key': result_key, } return render_template('admin/index.html', **ctx)
def console(): task = '' job = None result_key = None if request.method == 'POST': form = request.form task = form.get('task') if task: result_key = str(int(time.time())) db.log({ 'ip': request.remote_addr, 'user': session.get('user', {}).get('username'), 'command': task }) # run command job = queue_task(ops.run_fabric_task, task, result_key, False) ctx = { 'task': task, 'job': job, 'result_key': result_key, } return render_template('admin/console.html', **ctx)