Exemplo n.º 1
0
def on_exit(message='', prompt_obj=None, **kwargs):
    """Ctrl + D : exit,关闭命令行"""
    if prompt_obj is not None:
        prompt_obj.prompt_print('on_exit: %s' % message)
    _result = CResult(code='10100')
    _result.print_str = 'on_exit done!'
    return _result
Exemplo n.º 2
0
def on_abort(message='', prompt_obj=None, **kwargs):
    """Ctrl + C : abort,取消本次输入"""
    if prompt_obj is not None:
        prompt_obj.prompt_print('on_abort: %s' % message)
    _result = CResult()
    _result.print_str = 'on_abort done!'
    return _result
Exemplo n.º 3
0
def dir_cmd_dealfun(message='',
                    cmd='',
                    cmd_para='',
                    prompt_obj=None,
                    **kwargs):
    """dir命令的处理函数"""
    if prompt_obj is not None:
        prompt_obj.prompt_print('dir: message[%s], cmd[%s], cmd_para[%s]' %
                                (message, cmd, cmd_para))
    _result = CResult()
    _result.print_str = 'dir_cmd_dealfun done!'
    return _result
Exemplo n.º 4
0
def default_cmd_dealfun(message='',
                        cmd='',
                        cmd_para='',
                        prompt_obj=None,
                        **kwargs):
    """默认命令处理函数"""
    if prompt_obj is not None:
        prompt_obj.prompt_print(
            'cmd not define: message[%s], cmd[%s], cmd_para[%s]' %
            (message, cmd, cmd_para))
    _result = CResult()
    _result.print_str = 'default_cmd_dealfun done!'
    return _result
Exemplo n.º 5
0
def common_cmd_dealfun(message='',
                       cmd='',
                       cmd_para='',
                       prompt_obj=None,
                       **kwargs):
    """通用命令处理函数,持续10秒每秒输出一个wait的信息"""
    if prompt_obj is not None:
        prompt_obj.prompt_print('common: message[%s], cmd[%s], cmd_para[%s]' %
                                (message, cmd, cmd_para))

    if cmd == 'wait':
        _i = 0
        while _i < 10:
            _logger.info('wait ' + str(_i))
            _i = _i + 1
            time.sleep(1)

    _result = CResult()
    _result.print_str = 'common_cmd_dealfun done!'
    return _result