def onA(pressed): global currentApp, apps if pressed: display.drawFill(0x000000) drawMessageBox("Loading app...") display.flush() system.start(apps[currentApp]["path"])
def install_app(pressed=True): global category if pressed: slug = category[myList.selected_index()]["slug"] #Input handling try: ugfx.input_attach(ugfx.BTN_START, btn_exit) except: pass try: ugfx.input_attach(ugfx.BTN_SELECT, btn_unhandled) except: pass ugfx.input_attach(ugfx.BTN_A, btn_unhandled) ugfx.input_attach(ugfx.BTN_B, btn_unhandled) ugfx.input_attach(ugfx.JOY_UP, btn_unhandled) ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled) ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled) ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled) category = [] myList.clear() showMessage("Installing " + slug + "...") with open("/cache/installList", "w") as f: f.write(slug) system.start("dashboard._installer_exec")
def set_nickname(): rgb.clear() uinterface.skippabletext('Set nickname:') new_name = uinterface.text_input() if new_name is not None and new_name != '': machine.nvs_setstr('badge', 'nickname', new_name) system.start('nickname')
def _next(): import valuestore ## Start next app by restarting slider print('rebooting into next app: ', next_index) valuestore.save('slider', 'current', next_index) system.start('slider') pass
def start(c, force=False): system.start( 'etcd', 'nohup /opt/etcd/etcd --config-file={conf} >> {log} 2>&1 &'.format( conf=local.conf, log=local.logs), force=force, count=local.count)
def onA(pressed): global currentApp, apps if pressed: display.drawFill(0x000000) drawMessageBox("Loading app...") display.flush(display.FLAG_LUT_FASTEST) time.sleep(0.1) system.start(apps[currentApp]["path"])
def start_node(c): system.start( local.node_name, system.nohup( 'cd {}; nohup ./node_exporter --web.listen-address=":{}"'.format( base(local.node_name), local.node_port), nohup=''), pty=True)
def uninstall(app): if app["category"] == "system": # dialogs.notice("System apps can not be removed!","Can not uninstall '"+currentListTitles[selected]+"'") rgb.clear() uinterface.skippabletext("System apps can't be removed") render_current_app() return machine.nvs_setstr('launcher', 'uninstall_name', app['title']) machine.nvs_setstr('launcher', 'uninstall_file', app['file']) system.start('uninstall')
def splash_about_countdown_trigger(): global splashAboutCountdown try: splashAboutCountdown except: splash_about_countdown_reset() splashAboutCountdown -= 1 if splashAboutCountdown < 0: system.start('magic', False) else: print("[SPLASH] Magic in " + str(splashAboutCountdown) + "...")
def uninstall(app): global nvs if app["category"] == "system": # dialogs.notice("System apps can not be removed!","Can not uninstall '"+currentListTitles[selected]+"'") rgb.clear() uinterface.skippabletext("System apps can't be removed") render_current_app() return nvs.set_blob('uninstall_name', app['title']) nvs.set_blob('uninstall_file', app['file']) nvs.commit() system.start('uninstall')
def install_app(pressed=True): global category if pressed: slug = category[myList.selected_index()]["slug"] #Input handling ugfx.input_attach(ugfx.BTN_A, btn_unhandled) ugfx.input_attach(ugfx.BTN_B, btn_unhandled) ugfx.input_attach(ugfx.BTN_C, btn_unhandled) ugfx.input_attach(ugfx.BTN_BOOT, btn_unhandled) category = [] myList.clear() showMessage("Installing " + slug + "...") with open("/cache/installList", "w") as f: f.write(slug) system.start("dashboard._installer_exec")
def install_app(pressed=True): global category if pressed: slug = category[selectBox.selected_index()]["slug"] #Input handling ugfx.input_attach(ugfx.BTN_BACK, btn_unhandled) ugfx.input_attach(ugfx.BTN_OK, btn_unhandled) ugfx.input_attach(ugfx.JOY_UP, btn_unhandled) ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled) ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled) ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled) category = [] selectBox.clear() easydraw.messageCentered("Installing...\n" + slug, True, "/media/busy.png") with open("/cache/installList", "w") as f: f.write(slug) system.start("dashboard._installer_exec")
def opt_downloader(self): system.start("dashboard.terminal.downloader", True)
def opt_configure_led(self): system.start("dashboard.terminal.ledservice", True)
def opt_configure_picture(self): system.start("dashboard.terminal.picture", True)
def opt_about(self): system.start("about", True)
def opt_configure_services(self): system.start("dashboard.terminal.services", True)
# /etc/bashrc import sys if __name__ == '__main__': arg_list = sys.argv if arg_list[1] == "version": import version version.get_version(url="/system/v1/version") elif arg_list[1] == "system": try: if arg_list[2] == "start": import system system.start(url="/system/v1/login") print("SubwayTraffic service running") elif arg_list[2] == "status": import service_status service_status.show_status(url="/system/v1/live") elif arg_list[2] == "stop": import stop stop.stop(url="/system/v1/process") else: print("bash: command not found") except IndexError: print("bash: command not found") elif arg_list[1] == "stop": import stop stop.stop(url="/system/v1/process") elif arg_list[1] == "user": try:
def start(c): c = hosts.conn(0) c.run('cd {}; nohup bin/zookeeper-server-start.sh config/zookeeper.properties 1>zookeeper.log 2>&1 &'.format(local.base)) system.start('kafka.Kafka', 'cd {}; nohup bin/kafka-server-start.sh config/server.properties 1>/dev/null 2>&1 &'.format(local.base))
info_file = "%s/%s/metadata.json" % (install_path, app) print("Reading " + info_file + "...") with open(info_file) as f: information = f.read() return ujson.loads(information) except BaseException as e: print("[ERROR] Can not read metadata for app " + app) sys.print_exception(e) information = {"name": app, "title": "---", "category": ""} return information def expandhome(s): if "~/" in s: h = os.getenv("HOME") s = s.replace("~/", h + "/") return s term.empty_lines() term.header("Loading application list...") populate_apps() populate_category() currentListTitles.append("< Back to the main menu") selected = term.menu("Application launcher", currentListTitles) if selected == len(currentListTitles) - 1: system.home() else: system.start(currentListTargets[selected]['file'])
def btn_update(pressed): if pressed: repo.update() system.start("installer", True)
def opt_installer(self): system.start("dashboard.terminal.installer", True)
def opt_change_nickname(self): system.start("dashboard.terminal.nickname", True)
def run(): system.start(apps[current_index]["file"], status=True)
def run(): global options selected = options.selected_index() options.destroy() global currentListTargets system.start(currentListTargets[selected]["file"], True)
def opt_configure_wifi(self): system.start("dashboard.terminal.wifi", True)
def on_key(k, p): global tcp global page if p: if page == 0: x, y = k % 4, int(k / 4) if (x == 0 and y == 0): tcp.send_text("red") if (x == 1 and y == 0): tcp.send_text("green") if (x == 2 and y == 0): tcp.send_text("blue") if (x == 0 and y == 1): tcp.send_int32(42) if (x == 1 and y == 1): tcp.send_int32(-10) if (x == 2 and y == 1): tcp.send_int32(2147483647) if (x == 0 and y == 2): tcp.send_float(0) if (x == 1 and y == 2): tcp.send_double(0) if (x == 2 and y == 2): print("noh") if x == 0 and y == 3: print("restarting") dp.drawFill(0xa15b00) system.start(system.currentApp()) if x == 3 and y == 3: print("reconnecting") tcp.reconnect() #print("key:" + str(k) + " coords x:" + str(x) + " y:" + str(y)) elif page == 1: x, y = k % 4, int(k / 4) if k == 0: tcp.rgb.clear() if k == 1: tcp.rgb.disablecomp() if k == 2: tcp.rgb.enablecomp() if k == 3: tcp.rgb.frame([ 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 255, 255, 255, 255, 255, 255, 255, 255, 4227327, 4227327, 4227327, 255, 255, 4227327, 4227327, 4227327, 4278190335, 4227327, 4227327, 4227327, 4227327, 4278190335, 4278190335, 4278190335, 4278190335, 4227327, 4227327, 4227327, 4227327, 4278190335, 4278190335, 255, 4286644223, 4286644223, 4286644223, 4286644223, 4278223103, 4286644223, 255, 2155905279, 255, 255, 255, 2155905279, 255, 4227327, 4227327, 4227327, 4286578943, 4278190335, 4278190335, 4278190335, 4278190335, 4286578943, 4286578943, 4286578943, 4286578943, 4278190335, 4278190335, 4278190335, 4278190335, 4286578943, 4286578943, 255, 4286644223, 4278223103, 4286644223, 4286644223, 4286644223, 255, 2155905279, 4294967295, 255, 2155905279, 4294967295, 255, 2155905279, 255, 4227327, 4227327, 4294902015, 4286578943, 4286578943, 4286578943, 4286578943, 4294902015, 4294902015, 4294902015, 4294902015, 4286578943, 4286578943, 4286578943, 4286578943, 4294902015, 4294902015, 255, 4286644223, 4286644223, 4286644223, 4278223103, 4286644223, 255, 2155905279, 255, 255, 2155905279, 255, 255, 2155905279, 255, 4227327, 4227327, 16711935, 4294902015, 4294902015, 4294902015, 4294902015, 16711935, 16711935, 16711935, 16711935, 4294902015, 4294902015, 4294902015, 4294902015, 16711935, 16711935, 255, 4286644223, 4286644223, 4286644223, 4286644223, 4286644223, 255, 4286611711, 2155905279, 2155905279, 2155905279, 2155905279, 2155905279, 4286611711, 255, 4227327, 4227327, 8454143, 16711935, 16711935, 16711935, 16711935, 8454143, 8454143, 8454143, 8454143, 16711935, 16711935, 16711935, 16711935, 8454143, 8454143, 255, 4286644223, 4278223103, 4286644223, 4286644223, 4278223103, 4286644223, 255, 2155905279, 2155905279, 2155905279, 2155905279, 2155905279, 255, 4227327, 4227327, 4227327, 2147549183, 8454143, 8454143, 8454143, 8454143, 2147549183, 2147549183, 2147549183, 2147549183, 8454143, 8454143, 8454143, 8454143, 2147549183, 2147549183, 2147549183, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 4227327, 4227327, 4227327, 4227327, 4227327, 2147549183, 2147549183, 2147549183, 2147549183, 4227327, 4227327, 4227327, 4227327, 2147549183, 2147549183, 2147549183, 2147549183, 4227327, 4227327, 4227327, 4227327, 2147549183, 2147549183, 2147549183, 2147549183, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327, 4227327 ]) if k == 4: tcp.rgb.pixel((40, 40, 255), (3, 3)) if k == 5: tcp.rgb.text("Hello World", (150, 0, 0)) if k == 6: tcp.rgb.scrolltext("Hello World", (0, 150, 0)) if k == 7: tcp.rgb.image([ 0x00FF00FF, 0x00FF00FF, 0x00FF00FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF ], (0, 0), (3, 2)) if k == 8: tcp.rgb.gif([ 0x00FF00FF, 0x00FF00FF, 0x00FF00FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF ], (10, 1), (3, 1), 2) if k == 9: tcp.rgb.setfont(tcp.rgb.FONT_6x3) if k == 10: tcp.rgb.setfont(tcp.rgb.FONT_7x5) if x == 0 and y == 3: print("restarting") dp.drawFill(0xa15b00) system.start(system.currentApp()) if x == 3 and y == 3: print("reconnecting") tcp.reconnect()
def opt_configure_orientation(self): system.start("dashboard.terminal.orientation", True)
def opt_launcher(self): system.start("dashboard.terminal.launcher", True)
def opt_ota_check(self): system.start("checkforupdates", True)