Ejemplo n.º 1
0
    def delete_workspace(self, context, cb):
        host = yield self._get_host, context
        if not host:
            cb()
            return

        api_url = 'https://%s/api/workspaces/can/admin' % (host)

        try:
            r = api.api_request(host, api_url)
        except IOError as e:
            editor.error_message('Error getting workspaces can admin %s' %
                                 str_e(e))
            cb()
            return

        if r.code >= 400:
            editor.error_message('Error getting workspace list: %s' % r.body)
            cb()
            return

        choices = [
            '%s/%s' % (workspace['owner'], workspace['name'])
            for workspace in r.body
        ]
        (workspace, index) = yield self.user_select, context, 'Select workpace to delete', choices, []

        if not workspace:
            cb()
            return

        if G.EXPERT_MODE:
            yes = True
        else:
            yes = yield self.user_y_or_n, context, 'Really delete %s?' % workspace, 'Yes'

        if not yes:
            cb()
            return

        workspace = r.body[index]

        try:
            api.delete_workspace(host, workspace['owner'], workspace['name'])
        except IOError as e:
            editor.error_message('Error deleting workspace' % str_e(e))
        cb()
Ejemplo n.º 2
0
    def delete_workspace(self, context, cb):
        host = yield self._get_host, context
        if not host:
            cb()
            return

        api_url = 'https://%s/api/workspaces/can/admin' % (host)

        try:
            r = api.api_request(host, api_url)
        except IOError as e:
            editor.error_message('Error getting workspaces can admin %s' % str_e(e))
            cb()
            return

        if r.code >= 400:
            editor.error_message('Error getting workspace list: %s' % r.body)
            cb()
            return

        choices = ['%s/%s' % (workspace['owner'], workspace['name']) for workspace in r.body]
        (workspace, index) = yield self.user_select, context, 'Select workpace to delete', choices, []

        if not workspace:
            cb()
            return

        if G.EXPERT_MODE:
            yes = True
        else:
            yes = yield self.user_y_or_n, context, 'Really delete %s?' % workspace, 'Yes'

        if not yes:
            cb()
            return

        workspace = r.body[index]

        try:
            api.delete_workspace(host, workspace['owner'], workspace['name'])
        except IOError as e:
            editor.error_message('Error deleting workspace' % str_e(e))
        cb()
Ejemplo n.º 3
0
    def delete_workspace(self, context, cb):
        host = yield self._get_host, context
        if not host:
            cb()
            return

        api_url = "https://%s/api/workspaces/can/admin" % (host)

        try:
            r = api.api_request(host, api_url)
        except IOError as e:
            editor.error_message("Error getting workspaces can admin %s" % str_e(e))
            cb()
            return

        if r.code >= 400:
            editor.error_message("Error getting workspace list: %s" % r.body)
            cb()
            return

        choices = ["%s/%s" % (workspace["owner"], workspace["name"]) for workspace in r.body]
        (workspace, index) = yield self.user_select, context, "Select workpace to delete", choices, []

        if not workspace:
            cb()
            return

        if G.EXPERT_MODE:
            yes = True
        else:
            yes = yield self.user_y_or_n, context, "Really delete %s?" % workspace, "Yes"

        if not yes:
            cb()
            return

        workspace = r.body[index]

        try:
            api.delete_workspace(host, workspace["owner"], workspace["name"])
        except IOError as e:
            editor.error_message("Error deleting workspace" % str_e(e))
        cb()
Ejemplo n.º 4
0
def get_now_editing_workspaces():
    api_url = 'https://%s/api/workspaces/now_editing' % (G.DEFAULT_HOST)
    return api.api_request(G.DEFAULT_HOST, api_url)
Ejemplo n.º 5
0
def get_now_editing_workspaces():
    api_url = 'https://%s/api/workspaces/now_editing' % (G.DEFAULT_HOST)
    return api.api_request(G.DEFAULT_HOST, api_url)