def menu(self, args):
        from src.actions import build_bamboo_facade
        bamboo_facade = build_bamboo_facade()
        dashboard = bamboo_facade.dashboard()
        workflow().add_item(title=dashboard.agent_summary,
                            largetext=dashboard.agent_summary,
                            arg=':dashboard viewAgents',
                            icon=self._icon_for_overall_status(dashboard.status),
                            valid=True)
        for q in dashboard.builds:
            try:
                agent_name = 'on {}'.format(q['agent']['name']) if 'agent' in q else ''
                workflow().add_item(title='{}: {}'.format(q['planName'], q['jobName']),
                                    subtitle='{}: {} {}'.format(q['messageType'], q['messageText'], agent_name),
                                    largetext=q['messageType'],
                                    icon=self._icon_for_build_status(q['messageType']),
                                    arg=':dashboard {}'.format(q['resultKey']),
                                    modifier_subtitles={u'shift': u'Stop currently running build'},
                                    # `cmd``, ``ctrl``, ``shift``, ``alt`` and ``fn``
                                    valid=True)
            except:
                # sometimes the build results JSON does not contain proper build items
                pass

        workflow().add_item('Main menu', autocomplete='', icon=icons.GO_BACK)
 def execute(self, args, ctrl_pressed, shift_pressed):
     plan_key = args[-1]
     if shift_pressed:
         try:
             facade = build_bamboo_facade()
             facade.trigger_build(plan_key)
             print('Successfully triggered build for {}'.format(plan_key))
         except Exception, e:
             print('Failed to trigger build for {}: {}'.format(plan_key, str(e)))
 def execute(self, args, ctrl_pressed, shift_pressed):
     import webbrowser
     build_result_key, plan_key = args[-2], args[-1]
     if ctrl_pressed:
         build_results = get_data_from_cache(STATUS_CACHE_KEY, UPDATE_INTERVAL_STATUS)
         build_result = next((br for br in build_results if br.build_result_key == build_result_key), None)
         webbrowser.open(build_result.artifact_href)
     elif shift_pressed:
         try:
             facade = build_bamboo_facade()
             facade.trigger_build(plan_key)
             print('Successfully triggered build for {}'.format(build_result_key))
         except Exception, e:
             print('Failed to trigger build for {}: {}'.format(build_result_key, str(e)))
 def execute(self, args, ctrl_pressed, shift_pressed):
     import webbrowser
     host_url = workflow().settings.get(HOST_URL)
     if args[-1] == 'viewAgents':
         webbrowser.open('{}/admin/agent/viewAgents.action'.format(host_url))
     elif shift_pressed:
         from src.actions import build_bamboo_facade
         bamboo_facade = build_bamboo_facade()
         try:
             bamboo_facade.stop_build(args[-1])
             print('Successfully stopped build for {}'.format(args[-1]))
         except Exception, e:
             workflow().logger.debug('workflow ' + str(e))
             print('Failed to stop build for {}: {}'.format(args[-1], str(e)))
def main(wf):
    bamboo_facade = build_bamboo_facade()
    _fetch_bamboo_data_if_necessary(bamboo_facade)