Did I find the right examples for you? yes no

All Samples(22)  |  Call(16)  |  Derive(0)  |  Import(6)
Given an iterable, enumerate its contents for a user to choose from.
If the optional `attr` is not None, that attribute in each iterated
object will be printed.

This function will exit the program if the user chooses the escape option.

        def option_chooser(options, attr=None):
    """Given an iterable, enumerate its contents for a user to choose from.
    If the optional `attr` is not None, that attribute in each iterated
    object will be printed.

    This function will exit the program if the user chooses the escape option.
    """
    for num, option in enumerate(options):
        if attr:
            print("%s: %s" % (num, getattr(option, attr)))
        else:
            print("%s: %s" % (num, option))
    # Add an escape option
    escape_opt = num + 1
    print("%s: I want to exit!" % escape_opt)
    choice = raw_input("Selection: ")
    try:
        ichoice = int(choice)
        if ichoice > escape_opt:
            raise ValueError
    except ValueError:
        print("Valid entries are the numbers 0-%s. Received '%s'." % (escape_opt,
                choice))
        sys.exit()

    if ichoice == escape_opt:
        print("Bye!")
        sys.exit()

    return ichoice
        


src/p/y/pyrax-1.7.3/samples/cloud_monitoring/create_check.py   pyrax(Download)
import pyrax
 
from util import option_chooser
 
pyrax.set_setting("identity_type", "rackspace")
    sys.exit()
print("Select the entity on which you wish to create the notification:")
ent = option_chooser(ents, attr="name")
entity = ents[ent]
print(entity
)
aliases = entity.ip_addresses.items()
print("Select an IP address to check")
interface = option_chooser(aliases)
zones = cm.list_monitoring_zones()
print("Select a Monitoring Zone:")
zone_choice = option_chooser(zones, attr="label")
zone = zones[zone_choice]
 

src/p/y/pyrax-1.7.3/samples/cloud_monitoring/create_alarm.py   pyrax(Download)
import pyrax
 
from util import option_chooser
 
pyrax.set_setting("identity_type", "rackspace")
    sys.exit()
print("Select the entity on which you wish to create the notification:")
ent = option_chooser(ents, attr="name")
entity = ents[ent]
print(entity
)
checks = entity.list_checks()
print("Select a check to notify about:")
check_num = option_chooser(checks, attr="label")
 
plans = cm.list_notification_plans()
plan_num = option_chooser(plans, attr="label")
plan = plans[plan_num]
 

src/p/y/pyrax-HEAD/samples/cloud_monitoring/create_check.py   pyrax(Download)
import pyrax
 
from util import option_chooser
 
pyrax.set_setting("identity_type", "rackspace")
    sys.exit()
print("Select the entity on which you wish to create the notification:")
ent = option_chooser(ents, attr="name")
entity = ents[ent]
print(entity
)
aliases = entity.ip_addresses.items()
print("Select an IP address to check")
interface = option_chooser(aliases)
zones = cm.list_monitoring_zones()
print("Select a Monitoring Zone:")
zone_choice = option_chooser(zones, attr="label")
zone = zones[zone_choice]
 

src/p/y/pyrax-HEAD/samples/cloud_monitoring/create_alarm.py   pyrax(Download)
import pyrax
 
from util import option_chooser
 
pyrax.set_setting("identity_type", "rackspace")
    sys.exit()
print("Select the entity on which you wish to create the notification:")
ent = option_chooser(ents, attr="name")
entity = ents[ent]
print(entity
)
checks = entity.list_checks()
print("Select a check to notify about:")
check_num = option_chooser(checks, attr="label")
 
plans = cm.list_notification_plans()
plan_num = option_chooser(plans, attr="label")
plan = plans[plan_num]
 

src/p/y/pyrax-1.7.3/samples/cloud_monitoring/create_notification.py   pyrax(Download)
import pyrax
 
from util import option_chooser
 
pyrax.set_setting("identity_type", "rackspace")
    sys.exit()
print("Select the entity on which you wish to create the notification:")
ent = option_chooser(ents, attr="name")
entity = ents[ent]
print(entity
)
checks = entity.list_checks()
print("Select a check to notify about:")
check_num = option_chooser(checks, attr="label")

src/p/y/pyrax-HEAD/samples/cloud_monitoring/create_notification.py   pyrax(Download)
import pyrax
 
from util import option_chooser
 
pyrax.set_setting("identity_type", "rackspace")
    sys.exit()
print("Select the entity on which you wish to create the notification:")
ent = option_chooser(ents, attr="name")
entity = ents[ent]
print(entity
)
checks = entity.list_checks()
print("Select a check to notify about:")
check_num = option_chooser(checks, attr="label")