示例#1
0
def get_hooks():
    '''
    Returns all execution hooks.
    
    @return: list<CommandExecutionHook>
    '''
    return get_app_context()[APP_COMMANDER].get_hooks()
示例#2
0
def get_commands(parent=None,
                 name_filter=None,
                 description_filter=None,
                 exact_name=None):
    '''
    Returns all commands.
    If any filter specified, it filter those commands.

    @keyword str parent: only return commands that their parrents
        matches this string.
    @keyword str name_filter: only return commands that their names
        contain this string.
    @keyword str exact_name: only return command that its name
        is this string.
    @keyword str description_filter: only return commands that their
        description contain this string.

    @return: founded commands
    @rtype: list(dict(str name,
                      str description))
    '''
    return get_app_context()[APP_COMMANDER].get_commands(parent=parent,
                                                         name_filter=name_filter,
                                                         description_filter=description_filter,
                                                         exact_name=exact_name)
示例#3
0
def set_executor(executor):
    '''
    Registers a executor by the given name
    
    @param executor: executor instance
    '''
    return get_app_context()[APP_COMMANDER].set_executor(executor)
示例#4
0
def add_hook(hook):
    '''
    Adds a execution hook to the commander.
    
    @param hook:
    '''
    return get_app_context()[APP_COMMANDER].add_hook(hook)
示例#5
0
def remove_command(command):
    '''
    Removes the given command.
    
    @param command:
    '''
    return get_app_context()[APP_COMMANDER].remove_command(command)
示例#6
0
def remove_commands(parent):
    '''
    Removes all commands in the given parent domain.
    
    @param parent: parent name
    '''
    return get_app_context()[APP_COMMANDER].remove_commands(parent)
def register_cache_type(name, cache_type):
    '''
    Registers a cache type using specified name.
    @param name: registration name.
    @param type: class type.
    '''
    return get_app_context()[APP_CACHING].register_cache_type(name, cache_type)
def exists(name):
    '''
    Returns True if cache exists in cache manager.

    @return: bool
    '''

    return get_app_context()[APP_CACHING].exists(name)
示例#9
0
def execute(key, *args, **kargs):
    '''
    Executes a command by given key.
    
    @param key: command key or command name
    @return: object
    '''
    return get_app_context()[APP_COMMANDER].execute(key, *args, **kargs)
示例#10
0
def get_command(key):
    '''
    Returns the command by the given key.
    
    @param key: command key
    @return: command
    '''
    return get_app_context()[APP_COMMANDER].get_command(key)
示例#11
0
def add_command(command, **options):
    '''
    Adds a command.
    
    @param command: command instance
    '''
    
    return get_app_context()[APP_COMMANDER].add_command(command, 
                                                        **options)
def get_cache(name, cache_type_name = None, **cache_params):
    '''
    Returns the cache by given name. If the cache does not exists,
    This function creates a new cache by the given name and returns it.
    
    @param name: cache name.
    @param cache_type_name: type of cache.
    @param **cache_params: required parameters of specified cache type.  
    @return: Cache        
    '''          
    return get_app_context()[APP_CACHING].get_cache(name, cache_type_name, **cache_params)
示例#13
0
def execute_async(key, callback, *args, **kargs):
    '''
    Executes a command by given key.
    
    @param key: command key or command name
    @param callback: callback function
    @return: None 
    '''
    return get_app_context()[APP_COMMANDER].execute_async(key, 
                                                          callback, 
                                                          *args, 
                                                          **kargs)
示例#14
0
def bulk_execute(commands, **options):
    '''
    Executes a command by given key.
    
    @param commands: command data list as dict<command_key, args, kwargs>:
        command_key: command key
        args: command arguments
        kwargs: command keyword arguments
    @param **options: 
    @return: object
    '''
    
    return get_app_context()[APP_COMMANDER].bulk_execute(commands, **options)
示例#15
0
def select(fields, command_key, *args, **kwargs): 
    '''
    Executes a command and returns requested fields. 
    
    @param fields: list of requested fields 
    @param command_key: command key
    @param *args:
    @param **kwargs:
    
    @return: [DynamicObject<fields>]  
    '''
    
    return get_app_context()[APP_COMMANDER].select(fields, command_key, *args, **kwargs)
def add_hook(hook):
    return get_app_context()[APP_COMMUNICATOR].add_hook(hook)
def create_proxy_by_ticket(ticket, user_name, **kwargs):
    return get_app_context()[APP_COMMUNICATOR].create_proxy_by_ticket(
        ticket, user_name, **kwargs)
def create_proxy(user_name, password, **kwargs):
    return get_app_context()[APP_COMMUNICATOR].create_proxy(
        user_name, password, **kwargs)
def start(config_store=None):
    return get_app_context()[APP_COMMUNICATOR].start(config_store)
def stop(force=False):
    return get_app_context()[APP_COMMUNICATOR].stop(force)
def get_listener_params(name):
    return get_app_context()[APP_COMMUNICATOR].get_listener_params(name)
def get_listeners():
    return get_app_context()[APP_COMMUNICATOR].get_listeners()
def drop_cache(name):
    return get_app_context()[APP_CACHING].drop_cache(name)
def get_caches():
    return get_app_context()[APP_CACHING].get_caches()
示例#25
0
def get_executer():
    '''
    Returns defult executor.
    '''
    return get_app_context()[APP_COMMANDER].get_executer()
def get_hooks():
    return get_app_context()[APP_COMMUNICATOR].get_hooks()
def reset_cache(name):
    return get_app_context()[APP_CACHING].reset_cache(name)
def register_factory(type_name, factory):
    return get_app_context()[APP_COMMUNICATOR].register_factory(
        type_name, factory)
def add_cache(cache, replace = False):
    return get_app_context()[APP_CACHING].add_cache(cache, replace)