本文整理匯總了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)