本文整理匯總了Python中IPython.frontend.terminal.embed.InteractiveShellEmbed方法的典型用法代碼示例。如果您正苦於以下問題:Python embed.InteractiveShellEmbed方法的具體用法?Python embed.InteractiveShellEmbed怎麽用?Python embed.InteractiveShellEmbed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPython.frontend.terminal.embed
的用法示例。
在下文中一共展示了embed.InteractiveShellEmbed方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: make_shell
# 需要導入模塊: from IPython.frontend.terminal import embed [as 別名]
# 或者: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 別名]
def make_shell(init_func=None, banner=None, use_ipython=True):
"""Returns an action callback that spawns a new interactive
python shell.
:param init_func: an optional initialization function that is
called before the shell is started. The return
value of this function is the initial namespace.
:param banner: the banner that is displayed before the shell. If
not specified a generic banner is used instead.
:param use_ipython: if set to `True` ipython is used if available.
"""
if banner is None:
banner = 'Interactive Werkzeug Shell'
if init_func is None:
init_func = dict
def action(ipython=use_ipython):
"""Start a new interactive python session."""
namespace = init_func()
if ipython:
try:
try:
from IPython.frontend.terminal.embed import InteractiveShellEmbed
sh = InteractiveShellEmbed(banner1=banner)
except ImportError:
from IPython.Shell import IPShellEmbed
sh = IPShellEmbed(banner=banner)
except ImportError:
pass
else:
sh(global_ns={}, local_ns=namespace)
return
from code import interact
interact(banner, local=namespace)
return action
示例2: main
# 需要導入模塊: from IPython.frontend.terminal import embed [as 別名]
# 或者: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 別名]
def main():
opts = command_line()
print('Connecting...')
client = create_client_from_config(opts)
print('Connected.')
banner = '\nIMAPClient instance is "c"'
def ipython_011(c):
from IPython.frontend.terminal.embed import InteractiveShellEmbed
ipshell = InteractiveShellEmbed(banner1=banner)
ipshell('')
def ipython_010(c):
from IPython.Shell import IPShellEmbed
IPShellEmbed('', banner=banner)()
def builtin(c):
import code
code.interact(banner, local=dict(c=c))
for shell_attempt in (ipython_011, ipython_010, builtin):
try:
shell_attempt(client)
break
except ImportError:
pass
示例3: make_shell
# 需要導入模塊: from IPython.frontend.terminal import embed [as 別名]
# 或者: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 別名]
def make_shell(init_func=None, banner=None, use_ipython=True):
"""Returns an action callback that spawns a new interactive
python shell.
:param init_func: an optional initialization function that is
called before the shell is started. The return
value of this function is the initial namespace.
:param banner: the banner that is displayed before the shell. If
not specified a generic banner is used instead.
:param use_ipython: if set to `True` ipython is used if available.
"""
if banner is None:
banner = 'Interactive Werkzeug Shell'
if init_func is None:
init_func = dict
def action(ipython=use_ipython):
"""Start a new interactive python session."""
namespace = init_func()
if ipython:
try:
try:
from IPython.frontend.terminal.embed import InteractiveShellEmbed
sh = InteractiveShellEmbed(banner1=banner)
except ImportError:
from IPython.Shell import IPShellEmbed
sh = IPShellEmbed(banner=banner)
except ImportError:
pass
else:
sh(global_ns={}, local_ns=namespace)
return
from code import interact
interact(banner, local=namespace)
return action
示例4: setup_ipython
# 需要導入模塊: from IPython.frontend.terminal import embed [as 別名]
# 或者: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 別名]
def setup_ipython():
try:
import IPython
from IPython.config.loader import Config
from IPython.frontend.terminal.embed import InteractiveShellEmbed
cfg = Config()
cfg.PromptManager.in_template = "SimpleCV:\\#> "
cfg.PromptManager.out_template = "SimpleCV:\\#: "
#~ cfg.InteractiveShellEmbed.prompt_in1 = "SimpleCV:\\#> "
#~ cfg.InteractiveShellEmbed.prompt_out="SimpleCV:\\#: "
scvShell = InteractiveShellEmbed(config=cfg, banner1=banner,
exit_msg=exit_msg)
scvShell.define_magic("tutorial", magic_tutorial)
scvShell.define_magic("clear", magic_clear)
scvShell.define_magic("example", magic_examples)
scvShell.define_magic("forums", magic_forums)
scvShell.define_magic("walkthrough", magic_walkthrough)
scvShell.define_magic("docs", magic_docs)
except ImportError:
try:
from IPython.Shell import IPShellEmbed
argsv = ['-pi1', 'SimpleCV:\\#>', '-pi2', ' .\\D.:', '-po',
'SimpleCV:\\#>', '-nosep']
scvShell = IPShellEmbed(argsv)
scvShell.set_banner(banner)
scvShell.set_exit_msg(exit_msg)
scvShell.IP.api.expose_magic("tutorial", magic_tutorial)
scvShell.IP.api.expose_magic("clear", magic_clear)
scvShell.IP.api.expose_magic("example", magic_examples)
scvShell.IP.api.expose_magic("forums", magic_forums)
scvShell.IP.api.expose_magic("walkthrough", magic_walkthrough)
scvShell.IP.api.expose_magic("docs", magic_docs)
except ImportError:
raise
return scvShell()
示例5: main
# 需要導入模塊: from IPython.frontend.terminal import embed [as 別名]
# 或者: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 別名]
def main():
try:
try:
get_ipython
except NameError:
pass
else:
sys.exit("Running ipython inside ipython isn't supported. :(")
options, basic_auth, oauth, kerberos_auth = get_config()
if basic_auth:
basic_auth = handle_basic_auth(auth=basic_auth, server=options["server"])
if oauth.get("oauth_dance") is True:
oauth = oauth_dance(
options["server"],
oauth["consumer_key"],
oauth["key_cert"],
oauth["print_tokens"],
options["verify"],
)
elif not all(
(
oauth.get("access_token"),
oauth.get("access_token_secret"),
oauth.get("consumer_key"),
oauth.get("key_cert"),
)
):
oauth = None
use_kerberos = kerberos_auth.get("use_kerberos", False)
del kerberos_auth["use_kerberos"]
jira = JIRA(
options=options,
basic_auth=basic_auth,
kerberos=use_kerberos,
kerberos_options=kerberos_auth,
oauth=oauth,
)
import IPython
# The top-level `frontend` package has been deprecated since IPython 1.0.
if IPython.version_info[0] >= 1:
from IPython.terminal.embed import InteractiveShellEmbed
else:
from IPython.frontend.terminal.embed import InteractiveShellEmbed
ip_shell = InteractiveShellEmbed(
banner1="<Jira Shell " + __version__ + " (" + jira.client_info() + ")>"
)
ip_shell("*** Jira shell active; client is in 'jira'." " Press Ctrl-D to exit.")
except Exception as e:
print(e, file=sys.stderr)
return 2