Ejemplo n.º 1
0
def get_node(index, name=DEFAULT_SUBSCRIBE):
    all_servers = utils.read_from_json(SERVER_CONFIG)
    try:
        servers = all_servers[name]
    except KeyError:
        click.echo("No subscribe named %s found!" % name)
        sys.exit(1)
    node = servers[index]
    click.echo("switch to node:")
    utils.ping(name=name, index=index, all_servers=all_servers)
    return node
Ejemplo n.º 2
0
def get_node(index, name=DEFAULT_SUBSCRIBE):
    all_servers = utils.read_from_json(SERVER_CONFIG)
    try:
        servers = all_servers[name]
    except KeyError:
        click.echo("No subscribe named %s found!" % name)
        sys.exit(1)
    try:
        utils.check_index(index)
        node = servers[index - 1]
        click.echo("switch to node:")
        utils.ping(name=name, index=index, all_servers=all_servers)
    except IndexError:
        click.echo("Invalid index: %s, please check it." % index)
        sys.exit(1)
    return node
Ejemplo n.º 3
0
def ping(name, index):
    """test node delay by ping."""
    utils.ping(name=name, index=index)