本文整理汇总了Python中IPython.frontend.terminal.embed.InteractiveShellEmbed.banner方法的典型用法代码示例。如果您正苦于以下问题:Python InteractiveShellEmbed.banner方法的具体用法?Python InteractiveShellEmbed.banner怎么用?Python InteractiveShellEmbed.banner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.frontend.terminal.embed.InteractiveShellEmbed
的用法示例。
在下文中一共展示了InteractiveShellEmbed.banner方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: foo
# 需要导入模块: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.frontend.terminal.embed.InteractiveShellEmbed import banner [as 别名]
# They also print an exit message every time they exit.
# Both the startup banner and the exit message default to None, and can be set
# either at the instance constructor or at any other time with the
# by setting the banner and exit_msg attributes.
# The shell instance can be also put in 'dummy' mode globally or on a per-call
# basis. This gives you fine control for debugging without having to change
# code all over the place.
# The code below illustrates all this.
# This is how the global banner and exit_msg can be reset at any point
ipshell.banner = 'Entering interpreter - New Banner'
ipshell.exit_msg = 'Leaving interpreter - New exit_msg'
def foo(m):
s = 'spam'
ipshell('***In foo(). Try %whos, or print s or m:')
print 'foo says m = ',m
def bar(n):
s = 'eggs'
ipshell('***In bar(). Try %whos, or print s or n:')
print 'bar says n = ',n
# Some calls to the above functions which will trigger IPython:
print 'Main program calling foo("eggs")\n'
foo('eggs')
示例2: main
# 需要导入模块: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.frontend.terminal.embed.InteractiveShellEmbed import banner [as 别名]
#.........这里部分代码省略.........
# I don't know if we actually need volumes, but perhaps eventually...at least it's here now
nova_volume = client.Client(OS_USERNAME, OS_PASSWORD, OS_TENANT_NAME, OS_AUTH_URL, service_type="volume")
# XXX FIXME: Must be a better way to test the connection...
try:
nova_volume.volumes.list()
nova_compute.servers.list()
except:
print >>sys.stderr, "ERROR: Could not connect to OpenStack via nova python client"
sys.exit(1)
#
# Default variables
#
try:
WAIT = args.wait
TRIES = args.tries
except:
WAIT = 2
TRIES = 200
print "NOTICE: A required variable was not set"
# Set breed and breedfile variables
# XXX - should see if shell is set too
if args.BREED and args.BREEDFILE:
BREED = args.BREED
BREEDFILE = args.BREEDFILE
else:
# nothing to do
print "NOTICE: neither breed file or breed set so nothing to do"
sys.exit(0)
# open the breedfile
try:
stream = open(BREEDFILE, 'r')
except:
print >>sys.stderr, "ERROR: Failed to open " + BREEDFILE
sys.exit(1)
# load the breedfile
try:
breed = yaml.load(stream)
except:
print >>sys.stderr, "ERROR: " + BREEDFILE + " is not a valid yaml file"
sys.exit(1)
# If we asked for a shell, open one
# NOTE: Not going to go any farther than this
if args.SHELL:
#ipython_shell(nova)
ipshell = InteractiveShellEmbed()
ipshell.confirm_exit = False
ipshell.banner = ""
ipshell.prompt_manager.in_template = r'mastiff# '
ipshell.prompt_manager.in2_template = r'{color.Green}|{color.LightGreen}\D{color.Green}> '
ipshell.prompt_manager.out_template = r'<\#> '
ipshell()
print "Exiting IPython shell..."
sys.exit(0)
# Grab the breed we are looking for from the command line
# the idea being there could be several breeds in one config file
# maybe
instances = breed[str(BREED)]
servers = []
# Step through the instance information from the yaml file and boot a bunch of servers
for i, k in instances.iteritems():
for item in k:
# grab each required variable if it's there
if 'instances' in item:
num_instances = item['instances']
elif 'image' in item:
image = item['image']
elif 'playbook' in item:
playbook = item['playbook']
elif 'flavor' in item:
flavor = item['flavor']
if flavor is None:
flavor = 1
# Don't forget flavor XXX
if num_instances is not None and image is not None:
for j in range(int(num_instances)):
name = str(BREED) + ' ' + str(i) + ' ' + str(j)
server = nova_compute.servers.create(flavor=flavor,image=image,name=name)
if server:
servers.append(server)
#servers_up = False
#while servers_up = False:
# for server in servers:
# if server.status == "ACTIVE":
# try to get the IP address
sys.exit(0)