本文整理汇总了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)
示例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.")
示例3: shells
# 需要导入模块: import shell [as 别名]
# 或者: from shell import Shell [as 别名]
def shells(self):
return (Shell(sh) for sh in Topo(self))
示例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
示例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)