示例#1
0
文件: events.py 项目: stpierre/pulp
    def GET(self):
        manager = manager_factory.event_listener_manager()
        managers = manager.list()

        for m in managers:
            href = link.current_link_obj()
            m.update(href)

        return self.ok(managers)
示例#2
0
文件: events.py 项目: tomlanyon/pulp
    def GET(self):
        manager = manager_factory.event_listener_manager()
        managers = manager.list()

        for m in managers:
            href = link.current_link_obj()
            m.update(href)

        return self.ok(managers)
示例#3
0
文件: events.py 项目: stpierre/pulp
    def GET(self, event_listener_id):
        manager = manager_factory.event_listener_manager()

        event_listener_id = decode_unicode(event_listener_id)

        listener = manager.get(event_listener_id) # will raise MissingResource
        href = link.current_link_obj()
        listener.update(href)

        return self.ok(listener)
示例#4
0
文件: events.py 项目: tomlanyon/pulp
    def GET(self, event_listener_id):
        manager = manager_factory.event_listener_manager()

        event_listener_id = decode_unicode(event_listener_id)

        listener = manager.get(event_listener_id)  # will raise MissingResource
        href = link.current_link_obj()
        listener.update(href)

        return self.ok(listener)
示例#5
0
文件: plugins.py 项目: omps/pulp
    def GET(self, importer_type_id):
        manager = manager_factory.plugin_manager()
        all_importers = manager.importers()

        matching_importers = [i for i in all_importers if i['id'] == importer_type_id]

        if len(matching_importers) is 0:
            raise MissingResource(importer_type_id=importer_type_id)
        else:
            i = matching_importers[0]
            href = link.current_link_obj()
            i.update(href)

            return self.ok(i)
示例#6
0
文件: plugins.py 项目: omps/pulp
    def GET(self, type_id):
        manager = manager_factory.plugin_manager()
        all_types = manager.types()

        matching_types = [t for t in all_types if t['id'] == type_id]

        if len(matching_types) is 0:
            raise MissingResource(type=type_id)
        else:
            t = matching_types[0]
            href = link.current_link_obj()
            t.update(href)

            return self.ok(t)
示例#7
0
文件: plugins.py 项目: omps/pulp
    def GET(self, distributor_type_id):
        manager = manager_factory.plugin_manager()
        all_distributors = manager.distributors()

        matching_distributors = [d for d in all_distributors if d['id'] == distributor_type_id]

        if len(matching_distributors) is 0:
            raise MissingResource(distributor_type_id=distributor_type_id)
        else:
            d = all_distributors[0]
            href = link.current_link_obj()
            d.update(href)

            return self.ok(d)
示例#8
0
文件: events.py 项目: stpierre/pulp
    def PUT(self, event_listener_id):
        # Parameters
        params = self.params()

        notifier_config = params.get('notifier_config', None)
        event_types = params.get('event_types', None)

        # Execution
        manager = manager_factory.event_listener_manager()
        updated = manager.update(event_listener_id, notifier_config=notifier_config, event_types=event_types)

        href = link.current_link_obj()
        updated.update(href)

        return self.ok(updated)
示例#9
0
def http_error_obj(http_status, msg=None):
    """
    Serialize an http error.
    @param http_status: valid http status number
    @type http_status: int
    @param msg: error message
    @type: str
    @return: serialized error
    @rtype: dict
    """
    error_obj = copy.copy(_ERROR_OBJ_SKEL)
    error_obj['http_request_method'] = request_method()
    error_obj['http_status'] = http_status
    error_obj['error_message'] = msg
    error_obj.update(link.current_link_obj())
    return error_obj
示例#10
0
文件: events.py 项目: tomlanyon/pulp
    def PUT(self, event_listener_id):
        # Parameters
        params = self.params()

        notifier_config = params.get('notifier_config', None)
        event_types = params.get('event_types', None)

        # Execution
        manager = manager_factory.event_listener_manager()
        updated = manager.update(event_listener_id,
                                 notifier_config=notifier_config,
                                 event_types=event_types)

        href = link.current_link_obj()
        updated.update(href)

        return self.ok(updated)
示例#11
0
def exception_obj(e, tb=None, msg=None):
    """
    Serialize an (possibly unhandled) exception.
    @param e: exception
    @type e: Exception
    @param tb: traceback
    @type tb: traceback
    @param msg: error message
    @type msg: str
    @return: serialized error
    @rtype: dict
    """
    error_obj = copy.copy(_ERROR_OBJ_SKEL)
    error_obj['http_request_method'] = request_method()
    error_obj['error_message'] = msg
    error_obj['exception'] = traceback.format_exception_only(type(e), e)
    error_obj['traceback'] = traceback.format_tb(tb)
    error_obj.update(link.current_link_obj())
    return error_obj