def get(self, errors=None): idx = 0 networks = [] p = re.compile( '.*?network=\\{.*?ssid=\\"(.*?)\\".*?psk=\\"(.*?)\\"\n?(.*?)\\}.*?', re.I | re.M | re.S) iterator = p.finditer(self.read_wpa_supplicant_config()) for m in iterator: networks.append({ 'idx': idx, 'ssid': m.group(1), 'ssid64': base64.b64encode(m.group(1).encode())[:5], 'psk': m.group(2), 'options': m.group(3) }) idx += 1 config = OrderedDict( [['ZYNTHIAN_WIFI_MODE', zynconf.get_current_wifi_mode()], ['ZYNTHIAN_WIFI_NETWORKS', networks]]) if self.genjson: self.write(config) else: self.render("config.html", body="wifi.html", config=config, title="Wifi", errors=errors)
def post(self): errors = [] try: action = self.get_argument('ZYNTHIAN_WIFI_ACTION') logging.debug("ACTION: {}".format(action)) except: action = "SET_MODE" try: if action == "ADD_NETWORK": newSSID = self.get_argument('ZYNTHIAN_WIFI_NEW_SSID') newPassword = self.get_argument('ZYNTHIAN_WIFI_NEW_PASSWORD') if newSSID and newPassword: self.add_new_network(newSSID, newPassword) elif action[:7] == "REMOVE_": delSSID = action[7:] self.remove_network(delSSID) elif action[:7] == "UPDATE_": updSSID = action[7:] updOptions = self.get_argument( 'ZYNTHIAN_WIFI_OPTIONS_{}'.format(updSSID)) self.update_network_options(updSSID, updOptions) elif action == "SET_MODE": wifi_mode = self.get_argument('ZYNTHIAN_WIFI_MODE') current_wifi_mode = zynconf.get_current_wifi_mode() if wifi_mode != current_wifi_mode: if wifi_mode == "on": if not zynconf.start_wifi(): errors.append("Can't start WIFI network!") elif wifi_mode == "hotspot": if not zynconf.start_wifi_hotspot(): errors.append("Can't start WIFI Hotspot!") else: if not zynconf.stop_wifi(): errors.append("Can't stop WIFI!") except Exception as e: errors.append(e) self.get(errors)
def get(self, errors=None): supplicant_data = re.sub(r'psk=".*?"', 'psk="' + WifiConfigHandler.passwordMask + '"', self.read_supplicant_data(), re.I | re.M | re.S ) p = re.compile('.*?network=\\{.*?ssid=\\"(.*?)\\".*?psk=\\"(.*?)\\".*?priority=(\d*).*?\\}.*?', re.I | re.M | re.S ) iterator = p.finditer(supplicant_data) config=OrderedDict([ ['ZYNTHIAN_WIFI_WPA_SUPPLICANT', { 'type': 'textarea', 'cols': 50, 'rows': 20, 'title': 'Advanced Config', 'value': supplicant_data }], ['ZYNTHIAN_WIFI_MODE', { 'type': 'select', 'title': 'Mode', 'value': zynconf.get_current_wifi_mode(), 'options': ["off", "on", "hotspot"], }] ]) networks = [] idx = 0 for m in iterator: networks.append({ 'idx': idx, 'ssid': m.group(1), 'ssid64': base64.b64encode(m.group(1).encode())[:5], 'psk': m.group(2), 'priority': m.group(3) }) idx+=1 config['ZYNTHIAN_WIFI_NETWORKS'] = networks if self.genjson: self.write(config) else: self.render("config.html", body="wifi.html", config=config, title="Wifi", errors=errors)
def get(self): # Get git info git_info_zyncoder = self.get_git_info("/zynthian/zyncoder") git_info_ui = self.get_git_info("/zynthian/zynthian-ui") git_info_sys = self.get_git_info("/zynthian/zynthian-sys") git_info_webconf = self.get_git_info("/zynthian/zynthian-webconf") git_info_data = self.get_git_info("/zynthian/zynthian-data") # Get Memory & SD Card info ram_info = self.get_ram_info() sd_info = self.get_sd_info() config = OrderedDict([ [ 'HARDWARE', { #'icon': 'glyphicon glyphicon-wrench', 'icon': 'glyphicon glyphicon-cog', 'info': OrderedDict( [[ 'RBPI_VERSION', { 'title': os.environ.get('RBPI_VERSION') } ], [ 'SOUNDCARD_NAME', { 'title': 'Soundcard', 'value': os.environ.get('SOUNDCARD_NAME'), 'url': "/hw-audio" } ], [ 'DISPLAY_NAME', { 'title': 'Display', 'value': os.environ.get('DISPLAY_NAME'), 'url': "/hw-display" } ], [ 'WIRING_LAYOUT', { 'title': 'Wiring', 'value': os.environ.get('ZYNTHIAN_WIRING_LAYOUT'), 'url': "/hw-wiring" } ], [ 'GPIO_EXPANDER', { 'title': 'GPIO Expander', 'value': self.get_gpio_expander(), 'url': "/hw-wiring" } ]]) } ], [ 'SYSTEM', { #'icon': 'glyphicon glyphicon-dashboard', 'icon': 'glyphicon glyphicon-tasks', 'info': OrderedDict( [[ 'OS_INFO', { 'title': "{}".format(self.get_os_info()) } ], [ 'BUILD_DATE', { 'title': 'Build Date', 'value': self.get_build_info()['Timestamp'], } ], [ 'RAM', { 'title': 'Memory', 'value': "{} ({}/{})".format(ram_info['usage'], ram_info['used'], ram_info['total']) } ], [ 'SD CARD', { 'title': 'SD Card', 'value': "{} ({}/{})".format(sd_info['usage'], sd_info['used'], sd_info['total']) } ], [ 'TEMPERATURE', { 'title': 'Temperature', 'value': self.get_temperature() } ]]) } ], [ 'MIDI', { 'icon': 'glyphicon glyphicon-music', 'info': OrderedDict( [[ 'PROFILE', { 'title': 'Profile', 'value': os.path.basename( os.environ.get( 'ZYNTHIAN_SCRIPT_MIDI_PROFILE', "")), 'url': "/ui-midi-options" } ], [ 'FINE_TUNING', { 'title': 'Fine Tuning', 'value': "{} Hz".format( os.environ.get( 'ZYNTHIAN_MIDI_FINE_TUNING', "440")), 'url': "/ui-midi-options" } ], [ 'MASTER_CHANNEL', { 'title': 'Master Channel', 'value': self.get_midi_master_chan(), 'url': "/ui-midi-options" } ], [ 'SINGLE_ACTIVE_CHANNEL', { 'title': 'Single Active Channel', 'value': self.bool2onoff( os.environ.get( 'ZYNTHIAN_MIDI_SINGLE_ACTIVE_CHANNEL', '0')), 'url': "/ui-midi-options" } ], [ 'ZS3_SUBSNAPSHOTS', { 'title': 'ZS3 SubSnapShots', 'value': self.bool2onoff( os.environ.get( 'ZYNTHIAN_MIDI_PROG_CHANGE_ZS3', '1')), 'url': "/ui-midi-options" } ]]) } ], [ 'SOFTWARE', { 'icon': 'glyphicon glyphicon-random', 'info': OrderedDict( [[ 'ZYNCODER', { 'title': 'zyncoder', 'value': "{} ({})".format( git_info_zyncoder['branch'], git_info_zyncoder['gitid'][0:7]), 'url': "https://github.com/zynthian/zyncoder/commit/{}" .format(git_info_zyncoder['gitid']) } ], [ 'UI', { 'title': 'zynthian-ui', 'value': "{} ({})".format(git_info_ui['branch'], git_info_ui['gitid'][0:7]), 'url': "https://github.com/zynthian/zynthian-ui/commit/{}" .format(git_info_ui['gitid']) } ], [ 'SYS', { 'title': 'zynthian-sys', 'value': "{} ({})".format(git_info_sys['branch'], git_info_sys['gitid'][0:7]), 'url': "https://github.com/zynthian/zynthian-sys/commit/{}" .format(git_info_sys['gitid']) } ], [ 'DATA', { 'title': 'zynthian-data', 'value': "{} ({})".format(git_info_data['branch'], git_info_data['gitid'][0:7]), 'url': "https://github.com/zynthian/zynthian-data/commit/{}" .format(git_info_data['gitid']) } ], [ 'WEBCONF', { 'title': 'zynthian-webconf', 'value': "{} ({})".format( git_info_webconf['branch'], git_info_webconf['gitid'][0:7]), 'url': "https://github.com/zynthian/zynthian-webconf/commit/{}" .format(git_info_webconf['gitid']) } ]]) } ], [ 'LIBRARY', { 'icon': 'glyphicon glyphicon-book', 'info': OrderedDict( [[ 'SNAPSHOTS', { 'title': 'Snapshots', 'value': str( self.get_num_of_files( os.environ.get('ZYNTHIAN_MY_DATA_DIR') + "/snapshots")), 'url': "/lib-snapshot" } ], [ 'USER_PRESETS', { 'title': 'User Presets', 'value': str( self.get_num_of_presets( os.environ.get('ZYNTHIAN_MY_DATA_DIR') + "/presets")), 'url': "/lib-presets" } ], [ 'USER_SOUNDFONTS', { 'title': 'User Soundfonts', 'value': str( self.get_num_of_files( os.environ.get('ZYNTHIAN_MY_DATA_DIR') + "/soundfonts")), 'url': "/lib-soundfont" } ], [ 'AUDIO_CAPTURES', { 'title': 'Audio Captures', 'value': str( self.get_num_of_files( os.environ.get('ZYNTHIAN_MY_DATA_DIR') + "/capture", "*.wav")), 'url': "/lib-captures" } ], [ 'MIDI_CAPTURES', { 'title': 'MIDI Captures', 'value': str( self.get_num_of_files( os.environ.get('ZYNTHIAN_MY_DATA_DIR') + "/capture", "*.mid")), 'url': "/lib-captures" } ]]) } ], [ 'NETWORK', { 'icon': 'glyphicon glyphicon-link', 'info': OrderedDict( [[ 'HOSTNAME', { 'title': 'Hostname', 'value': self.get_host_name(), 'url': "/sys-security" } ], [ 'WIFI', { 'title': 'Wifi', 'value': zynconf.get_current_wifi_mode(), 'url': "/sys-wifi" } ], [ 'IP', { 'title': 'IP', 'value': self.get_ip(), 'url': "/sys-wifi" } ], [ 'RTPMIDI', { 'title': 'RTP-MIDI', 'value': self.bool2onoff( self.is_service_active("jackrtpmidid")), 'url': "/ui-midi-options" } ], [ 'QMIDINET', { 'title': 'QMidiNet', 'value': self.bool2onoff( self.is_service_active("qmidinet")), 'url': "/ui-midi-options" } ]]) } ] ]) if self.is_service_active("touchosc2midi"): config['NETWORK']['info']['TOUCHOSC'] = { 'title': 'TouchOSC', 'value': 'on', 'url': "/ui-midi-options" } super().get("dashboard_block.html", "Dashboard", config, None)