Exemplo n.º 1
0
def handle_start(environ, start_response):
    cfg = config.read()
    ssid = str(cfg['wifi_hotspot_ssid'])
    password = str(cfg['wifi_hotspot_password'])
    success, message = start_hotspot(ssid, password)
    status = httplib.OK if success else httplib.BAD_GATEWAY
    start_response(status, [('Content-Type', 'text/plain')])
    yield message
Exemplo n.º 2
0
def handle_start(environ, start_response):
    cfg = config.read()
    ssid = cfg.get('fqrouter', 'WifiHotspotSSID')
    password = cfg.get('fqrouter', 'WifiHotspotPassword')
    success, message = start_hotspot(ssid, password)
    status = httplib.OK if success else httplib.BAD_GATEWAY
    start_response(status, [('Content-Type', 'text/plain')])
    yield message
Exemplo n.º 3
0
def handle_start(environ, start_response):
    cfg = config.read()
    ssid = str(cfg['wifi_hotspot_ssid'])
    password = str(cfg['wifi_hotspot_password'])
    success, message = start_hotspot(ssid, password)
    status = httplib.OK if success else httplib.BAD_GATEWAY
    start_response(status, [('Content-Type', 'text/plain')])
    yield message
Exemplo n.º 4
-1
    httpd.serve_forever()


def clean():
    setup_logging(LOG_FILE)
    LOGGER.info('clean...')
    dns_service.clean()
    tcp_service.clean()
    full_proxy_service.clean()
    lan_service.clean()
    wifi.clean()


if '__main__' == __name__:
    if len(sys.argv) > 1:
        shutdown_hook.shutdown_hooks = []
        action = sys.argv[1]
        if 'wifi-start-hotspot' == action:
            setup_logging(os.path.join(LOG_DIR, 'wifi.log'), maxBytes=1024 * 512)
            sys.stderr.write(repr(wifi.start_hotspot(*sys.argv[2:])))
        elif 'wifi-stop-hotspot' == action:
            setup_logging(os.path.join(LOG_DIR, 'wifi.log'), maxBytes=1024 * 512)
            sys.stderr.write(repr(wifi.stop_hotspot()))
        elif 'twitter-check' == action:
            setup_logging(os.path.join(LOG_DIR, 'twitter.log'), maxBytes=1024 * 64)
            sys.stderr.write(repr(twitter.check()))
        elif 'clean' == action:
            clean()
    else:
        run()