当前位置: 首页>>代码示例>>Python>>正文


Python readline.set_completion_display_matches_hook方法代码示例

本文整理汇总了Python中readline.set_completion_display_matches_hook方法的典型用法代码示例。如果您正苦于以下问题:Python readline.set_completion_display_matches_hook方法的具体用法?Python readline.set_completion_display_matches_hook怎么用?Python readline.set_completion_display_matches_hook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在readline的用法示例。


在下文中一共展示了readline.set_completion_display_matches_hook方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_command

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completion_display_matches_hook [as 别名]
def get_command(self, prompt, auto_complete_fn=None, basefile_fn=None):
        try:
            if auto_complete_fn != None:
                import readline
                readline.set_completer_delims(' \t\n;/')
                readline.parse_and_bind("tab: complete")
                readline.set_completer(auto_complete_fn)
                # readline.set_completion_display_matches_hook(basefile_fn)
        except:
            pass

        # python3 changes raw input name
        if sys.version_info[0] == 3:
            raw_input = input
        else:
            raw_input = __builtins__['raw_input']

        cmd = raw_input("%s" % prompt)
        return cmd.strip() 
开发者ID:zerosum0x0,项目名称:koadic,代码行数:21,代码来源:shell.py

示例2: __init__

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completion_display_matches_hook [as 别名]
def __init__(self, lhost, lport):
		self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
		self.lhost = lhost
		self.lport = lport
		self.framework = Framework(self.send_command, self.check_command, self.get_response)
		self.command_definition = {}
		self.credentials = []
		self.fast_load = False
		self.prompt = ""
		self.os_target = None
		
		# Define command behavior
		self.command_definition["Local-Invoke"] 				= lambda x: self.psh_Local_Invoke(x[len("Local-Invoke"):].strip())
		self.command_definition["Local-Import-Module"] 			= lambda x: self.psh_Local_Invoke(x[len("Local-Import-Module"):].strip(), True)
		self.command_definition["Local-Set-Width"] 				= lambda x: self.psh_Local_Set_Width(x[len("Local-Set-Width"):].strip())
		self.command_definition["Local-Upload"] 				= lambda x: self.psh_Local_Upload(x[len("Local-Upload"):].strip())
		self.command_definition["Local-Download"] 				= lambda x: self.psh_Local_Download(x[len("Local-Download"):].strip())
		self.command_definition["Local-Download-Commands"] 		= lambda x: self.psh_Local_Download_Commands()		
		self.command_definition["Local-Enumerate-System"] 		= lambda x: self.psh_Local_Enumerate_System()
		self.command_definition["Local-Check-Status"] 			= lambda x: self.psh_Local_Check_Status()
		self.command_definition["Local-Spawn-Meterpreter"]		= lambda x: self.psh_Local_Spawn_Shell(conf_name.METERPRETER)
		self.command_definition["Local-Spawn-Reverse-Shell"]	= lambda x: self.psh_Local_Spawn_Shell(conf_name.REVERSE_SHELL)
		self.command_definition["Local-Credential-Create"] 		= lambda x: self.psh_Local_Credential(True)
		self.command_definition["Local-Credential-List"] 		= lambda x: self.psh_Local_Credential()
		self.command_definition["clear"]						= lambda x: self.psh_Local_Clear()
				
		# Define autocomplete
		readline.parse_and_bind("tab: complete")
		readline.set_completer(self.cmd_complete)
		readline.set_completion_display_matches_hook(self.cmd_match_display_hook)
		readline.set_completer_delims("") 
开发者ID:z0noxz,项目名称:powerstager,代码行数:34,代码来源:powerstager.py

示例3: __init__

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completion_display_matches_hook [as 别名]
def __init__(self, options):
        """
        Constructor
        """
        readline.parse_and_bind("tab: complete")
        readline.set_completer(self.complete)
        readline.set_completion_display_matches_hook(self.completer_print)
        try:
            readline.read_history_file(CLI_HISTORY)
        except IOError:
            pass
        readline.set_history_length(CLI_MAX_CMD_HISTORY)

        if not os.path.isdir(CLI_RESULT_HISTORY_FOLDER):

            linux.rm_dir_force(os.path.dirname(CLI_RESULT_HISTORY_FOLDER))
            os.system('mkdir -p %s' % os.path.dirname(CLI_RESULT_HISTORY_FOLDER))

        try:
            self.hd = filedb.FileDB(CLI_RESULT_HISTORY_KEY, is_abs_path=True)
        except:
            linux.rm_dir_force(CLI_RESULT_HISTORY_KEY)
            self.hd = filedb.FileDB(CLI_RESULT_HISTORY_KEY, is_abs_path=True)
            print "\nRead history file: %s error. Has recreate it.\n" % CLI_RESULT_HISTORY_KEY

        self.start_key = 'start_key'
        self.last_key = 'last_key'
        self.cli_cmd_func = {'help': self.show_help,
                             'history': self.show_help,
                             'more': self.show_more,
                             'quit': sys.exit,
                             'exit': sys.exit,
                             'save': self.save_json_to_file}
        self.cli_cmd = self.cli_cmd_func.keys()

        self.raw_words_db = self._parse_api_name(inventory.api_names)
        self.words_db = list(self.raw_words_db)
        self.words_db.extend(self.cli_cmd)
        self.words = list(self.words_db)
        self.is_cmd = False
        self.curr_pattern = None
        self.matching_words = None
        self.api_class_params = {}
        self.build_api_parameters()
        self.api = None
        self.account_name = None
        self.user_name = None
        self.session_uuid = None
        if os.path.exists(SESSION_FILE):
            try:
                with open(SESSION_FILE, 'r') as session_file_reader:
                    self.session_uuid = session_file_reader.readline().rstrip()
                    self.account_name = session_file_reader.readline().rstrip()
                    self.user_name = session_file_reader.readline().rstrip()
            except EOFError:
                pass

        self.hostname = options.host
        self.port = options.port
        self.no_secure = options.no_secure
        self.api = api.Api(host=self.hostname, port=self.port) 
开发者ID:zstackio,项目名称:zstack-utility,代码行数:63,代码来源:cli.py


注:本文中的readline.set_completion_display_matches_hook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。