def start(port=8266, password=None, ssl=False): global key, cert, websslrepl if ssl: websslrepl = True port = 8833 _key = 'SSL_key{}.der'.format(hexlify(unique_id()).decode()) _cert = 'SSL_certificate{}.der'.format(hexlify(unique_id()).decode()) try: with open(_key, 'rb') as keyfile: key = keyfile.read() with open(_cert, 'rb') as certfile: cert = certfile.read() except Exception as e: print('No key or certificate found') else: websslrepl = False stop() if password is None: try: import webrepl_cfg _webrepl.password(webrepl_cfg.PASS) setup_conn(port, accept_conn) print("Started webrepl in normal mode") except: print("WebREPL is not configured, run 'import webrepl_setup'") else: _webrepl.password(password) setup_conn(port, accept_conn) print("Started webrepl in manual override mode")
def start(port=8266, password=None, accept_handler=accept_conn): global static_host stop() webrepl_pass = password if webrepl_pass is None: try: import webrepl_cfg webrepl_pass = webrepl_cfg.PASS if hasattr(webrepl_cfg, "BASE"): static_host = webrepl_cfg.BASE except: print("WebREPL is not configured, run 'import webrepl_setup'") _webrepl.password(webrepl_pass) s = setup_conn(port, accept_handler) if accept_handler is None: print("Starting webrepl in foreground mode") # Run accept_conn to serve HTML until we get a websocket connection. while not accept_conn(s): pass elif password is None: print("Started webrepl in normal mode") else: print("Started webrepl in manual override mode")
def start(port=8266): stop() try: import port_config _webrepl.password(port_config.WEBREPL_PASS) setup_conn(port, accept_conn) print("Started webrepl in normal mode") except: import webrepl_setup setup_conn(port, webrepl_setup.handle_conn) print("Started webrepl in setup mode")
def start(port=8266, password=None): stop() if password is None: cfg = config('webrepl') password = cfg.get('password') if not password: password = '******' print("WebREPL password is not configured, using default 1234") _webrepl.password(password) setup_conn(port, accept_conn) print("Started webrepl")
def start(port=8888, password=None): stop() if password is None: try: import settings _webrepl.password(settings.webrepl_password) setup_conn(port, accept_conn) print("Started webrepl in normal mode") except: print("WebREPL is not configured, run 'import webrepl_setup'") else: _webrepl.password(password) setup_conn(port, accept_conn) print("Started webrepl in manual override mode")
def start(port=8266, password=None): stop() if password is None: try: import webrepl_cfg _webrepl.password(webrepl_cfg.PASS) setup_conn(port, accept_conn) print("Started webrepl in normal mode") except: print("WebREPL is not configured, run 'import webrepl_setup'") else: _webrepl.password(password) setup_conn(port, accept_conn) print("Started webrepl in manual override mode")
def start(cls, port=8266, password=None): WebREPL().stop() if password is None: try: import webrepl_cfg _webrepl.password(webrepl_cfg.PASS) WebREPL().setup_conn(port, WebREPL().accept_conn) print("Started webrepl in normal mode") except: print("WebREPL is not configured, run 'import webrepl_setup'") else: _webrepl.password(password) WebREPL().setup_conn(port, WebREPL().accept_conn) print(rainbow("WebREPL started.", color='green'))
def start(cls, port=8266, password=None): WebREPL().stop() if password is None: try: import webrepl_cfg _webrepl.password(webrepl_cfg.PASS) WebREPL().setup_conn(port, WebREPL().accept_conn) print("WebREPL 将按配置启用") except: print("WebREPL 未初始化配置, 请运行 'import webrepl_setup'") else: _webrepl.password(password) WebREPL().setup_conn(port, WebREPL().accept_conn) print(rainbow("WebREPL 启动.", color='green'))
def start(port=8266, password="******"): stop() if password is None: try: import webrepl_cfg _webrepl.password(webrepl_cfg.PASS) setup_conn(port, accept_conn) print("Started webrepl in normal mode") except: print("WebREPL is not configured, run 'import webrepl_setup'") else: _webrepl.password(password) setup_conn(port, accept_conn) print("Started webrepl in manual override mode")
def start(self): self.stop() _webrepl.password(self._password) self._listen_sock = socket.socket() self._listen_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self._listen_sock.bind( socket.getaddrinfo(self._address, self._port)[0][4]) self._listen_sock.listen(1) # Register callback self._listen_sock.setsockopt(socket.SOL_SOCKET, 20, self._accept_handler) for i in (network.AP_IF, network.STA_IF): iface = network.WLAN(i) if iface.active(): return "ws://%s:%d" % (iface.ifconfig()[0], self._port) return ""
def start(port=8266, password=None, accept_handler=accept_conn): stop() webrepl_pass = password if webrepl_pass is None: try: import webrepl_cfg webrepl_pass = webrepl_cfg.PASS except: print("WebREPL is not configured, run 'import webrepl_setup'") _webrepl.password(webrepl_pass) s = setup_conn(port, accept_handler) if accept_handler is None: print("Starting webrepl in foreground mode") accept_conn(s) elif password is None: print("Started webrepl in normal mode") else: print("Started webrepl in manual override mode")