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


Python shell.Shell方法代码示例

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


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

示例1: connect

# 需要导入模块: import shell [as 别名]
# 或者: from shell import Shell [as 别名]
def connect(self, **kwargs):
        host = self.module.params['host']
        port = self.module.params['port'] or 22

        username = self.module.params['username']
        password = self.module.params['password']
        key_filename = self.module.params['ssh_keyfile']

        try:
            self.shell = Shell(kickstart=False, prompts_re=CLI_PROMPTS_RE, errors_re=CLI_ERRORS_RE)
            self.shell.open(host, port=port, username=username, password=password, key_filename=key_filename)
        except ShellError:
            e = get_exception()
            msg = 'failed to connect to %s:%s - %s' % (host, port, str(e))
            self.module.fail_json(msg=msg) 
开发者ID:ios-xr,项目名称:iosxr-ansible,代码行数:17,代码来源:iosxr.py

示例2: login

# 需要导入模块: import shell [as 别名]
# 或者: from shell import Shell [as 别名]
def login(username, password_entry):
    specfile = oth.SpecFile("users/"+username+"/default.spec")
    password = specfile.get("password")
    pass_hash = hashlib.sha256(bytes(password_entry.encode("utf-8"))).hexdigest()
    
    if pass_hash == password:
        newShell = shell.Shell(username, password_entry)
        newShell.start_loop()
    else:
        print("[PyOS]: Failed to log in to "+username+"'s shell.") 
开发者ID:Seanld,项目名称:py-os,代码行数:12,代码来源:boot.py

示例3: shells

# 需要导入模块: import shell [as 别名]
# 或者: from shell import Shell [as 别名]
def shells(self):
        return (Shell(sh) for sh in Topo(self)) 
开发者ID:chenkianwee,项目名称:py4design,代码行数:4,代码来源:solid.py

示例4: channel_opened

# 需要导入模块: import shell [as 别名]
# 或者: from shell import Shell [as 别名]
def channel_opened(self, peer, channel_type, local_cid, queue):
        if not channel_type:
            # channel_type is None when the we initiated the channel.
            return

        if channel_type == "mpeer":
            asyncio.async(\
                self._process_chord_packet(peer, local_cid, queue),\
                loop=self.loop)
            return
        elif channel_type == "session":
            self.shells[local_cid] =\
                shell.Shell(self.loop, peer, local_cid, queue)
            return 
开发者ID:bitcoinembassy,项目名称:morphis,代码行数:16,代码来源:chord.py

示例5: do_eval

# 需要导入模块: import shell [as 别名]
# 或者: from shell import Shell [as 别名]
def do_eval(caller):
        """Evaluates <code and prints the result to you.

        You can use MOO-style object numbers (#15 for example).

        Any semicolon (;) characters are replaced with \n so you can enter
        multiline code.

        The following globals are available:
        logger - The "commands.admin" logger.
        server - The main server object.
        All the members of the db module.
        reactor - The twisted reactor.
        caller - The caller which was sent with this command.
        con - Your connection.
        player - Your player object.
        account - Your account object."""
        player = caller.connection.player
        if player.id not in shells:
            shells[player.id] = Shell(player)
        shell = shells[player.id]
        shell.locals['caller'] = caller
        shell.locals['here'] = player.location
        code = re.sub(
            r'(\#([0-9]+))',
            r'toobj(\2)',
            caller.args_str
        )
        shell.push(code.replace(';', '\n') + '\n')
        logger.info('%s eval: "%s"', player, code) 
开发者ID:chrisnorman7,项目名称:game,代码行数:32,代码来源:admin.py


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