當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。