def set_boot_mode(): print(print_as_a_list_item(0, '清除模式', '注意: 清除引导程序 boot.py, 这将导致程序无法启动!')) print(print_as_a_list_item(1, 'WiFi模式', '此选项适合稳定程序使用!')) print(print_as_a_list_item(2, '开发者模式', '启动连接WIFI热点,并开启WebREPL开发模式')) mode = selection('请选择模式 [0-2]: ', 2) with open('boot.py', 'w') as f: if mode == BOOT_MODE.WITH_NOTHING: boot_code = '' f.write(boot_code) print(rainbow('已设置为清除模式', color='green')) elif mode == BOOT_MODE.WITH_WIFI_STARTUP: boot_code = BOOT_MODE.WITH_WIFI_STARTUP_CODE f.write(boot_code) print(rainbow('已设置为WiFi模式', color='green')) elif mode == BOOT_MODE.EASY_DEVELOP: config_path() if not 'webrepl.pass' in os.listdir('config'): with open('config/webrepl.pass', 'w') as c: c.write('123456') boot_code = BOOT_MODE.EASY_DEVELOP_CODE f.write(boot_code) print(rainbow('已设置为开发者模式', color='green')) reboot()
def set_boot_mode(): print( print_as_a_list_item( 0, 'Boot with nothing', 'attention: this option will clear up boot.py, careful!')) print( print_as_a_list_item( 1, 'Boot with wifi startup', 'this mode will auto start wifi connect program.')) print( print_as_a_list_item( 2, 'Easy to develop', 'this mode is for developers.In this mode you can develop much easier via EMP-IDE(emp.1zlab.com)' )) mode = selection('Please input your choice [0-2]: ', 2) with open('boot.py', 'w') as f: if mode == BOOT_MODE.WITH_NOTHING: boot_code = '' f.write(boot_code) print(rainbow('Boot mode set to WITH_NOTHING', color='green')) elif mode == BOOT_MODE.WITH_WIFI_STARTUP: boot_code = BOOT_MODE.WITH_WIFI_STARTUP_CODE f.write(boot_code) print(rainbow('Boot mode set to WITH_WIFI_STARTUP', color='green')) elif mode == BOOT_MODE.EASY_DEVELOP: config_path() if not 'webrepl.pass' in os.listdir('config'): with open('config/webrepl.pass', 'w') as c: c.write('1zlab') boot_code = BOOT_MODE.EASY_DEVELOP_CODE f.write(boot_code) print(rainbow('Boot mode set to EASY_DEVELOP', color='green')) reboot()
def update_profile(cls, config): config_path() with open(cls._profile, 'w') as f: f.write(json.dumps(config))
def set_web_repl(): pw = input(rainbow('请输入新的WebREPL密码:', color='blue')) config_path() with open('config/webrepl.pass', 'w') as c: c.write(pw) print(rainbow('已重新设置WebREPL密码,重启之后可用!!!', color='green'))