def handle_stop(environ, start_response): start_response(httplib.OK, [('Content-Type', 'text/plain')]) yield stop_hotspot()
def handle_reset(environ, start_response): start_response(httplib.OK, [('Content-Type', 'text/plain')]) enable_wifi_p2p_service() restore_config_files() stop_hotspot() return []
def wifi_reset(): wifi.enable_wifi_p2p_service() wifi.restore_config_files() wifi.stop_hotspot()
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()