Esempio n. 1
0
def cli(host, port, wwwport):
    click.echo('\r\nService listening on %s:%s' % (
        host,
        port,
    ))

    web_list = list()
    client_connect_list = list()
    web_list.append('local: http://127.0.0.1:%s' % wwwport)
    client_connect_list.append(
        'local: python client.py --host 127.0.0.1 --port %s' % port)
    if host == '0.0.0.0':
        wan_ip = get_wan_ip()
        lan_ip = socket.gethostbyname(socket.gethostname())
        if lan_ip != wan_ip:
            web_list.append('lan  : http://%s:%s' % (lan_ip, wwwport))
            client_connect_list.append(
                'lan  : python client.py --host %s --port %s' % (lan_ip, port))

        if wan_ip:
            web_list.append(
                'wan  : http://%s:%s  PS: Maybe need to set up port forwarding'
                % (wan_ip, wwwport))
            client_connect_list.append(
                'wan  : python client.py --host %s --port %s  PS: Maybe need to set up port forwarding'
                % (wan_ip, port))

    click.echo('\r\nAccess console via:')
    for item in web_list:
        click.echo(item)

    click.echo('\r\nClient connection use:')
    for item in client_connect_list:
        click.echo(item)

    click.echo('\r\nListening ...')

    global_process_var = Manager().dict()
    GlobalHelper.init(global_process_var)

    web_ui = Process(target=web_start,
                     args=(global_process_var, host, wwwport))
    web_ui.start()

    global slave_record
    slave_record = SlaveRecord.get_instance()
    GlobalHelper.set('salve_record', slave_record.slave_record)

    socket_server(host, port)
    web_ui.join()
Esempio n. 2
0
def cli(host, port, wwwport):
    click.echo('\r\nService listening on %s:%s' % (host, port,))

    web_list = list()
    client_connect_list = list()
    web_list.append('local: http://127.0.0.1:%s' % wwwport)
    client_connect_list.append('local: python client.py --host 127.0.0.1 --port %s' % port)
    if host == '0.0.0.0':
        wan_ip = get_wan_ip()
        lan_ip = socket.gethostbyname(socket.gethostname())
        if lan_ip != wan_ip:
            web_list.append('lan  : http://%s:%s' % (lan_ip, wwwport))
            client_connect_list.append('lan  : python client.py --host %s --port %s' % (lan_ip, port))

        if wan_ip:
            web_list.append('wan  : http://%s:%s  PS: Maybe need to set up port forwarding' % (wan_ip, wwwport))
            client_connect_list.append(
                'wan  : python client.py --host %s --port %s  PS: Maybe need to set up port forwarding' %
                (wan_ip, port))

    click.echo('\r\nAccess console via:')
    for item in web_list:
        click.echo(item)

    click.echo('\r\nClient connection use:')
    for item in client_connect_list:
        click.echo(item)

    click.echo('\r\nListening ...')

    global_process_var = Manager().dict()
    GlobalHelper.init(global_process_var)

    web_ui = Process(target=web_start, args=(global_process_var, host, wwwport))
    web_ui.start()

    global slave_record
    slave_record = SlaveRecord.get_instance()
    GlobalHelper.set('salve_record', slave_record.slave_record)

    socket_server(host, port)
    web_ui.join()
Esempio n. 3
0
import click
from functions import get_wan_ip
import socket
print socket.gethostbyname(socket.gethostname())

print get_wan_ip()

#
# @click.command()
# @click.option('--name', prompt='Your name',
#               help='The person to greet.')
# def hello(name):
#     """Simple program that greets NAME for a total of COUNT times."""
#     click.echo('Hello %s!' % name)
#
#
# if __name__ == '__main__':
#     hello()
#     print 123123