def confirm(): ssid = request.args.get("ssid", "") ssid_encoded = urllib.parse.quote(ssid.encode()) encrypted = request.args.get("encrypted", "unencrypted") # networkmanager only lists the active hotspot access point if it is the running on the only wifi device available. # iwscan however, works regardless, so check the authentication details with that. # TODO: move this into the comitup service and add command-line access as well is_8021x = next(can for can in candidates() if can['ssid'] == ssid)\ ['is_enterprise'] == 'True' ias_login_scripts = [ f.name for f in os.scandir(PUPPETEER_SCRIPT_FILEPATH) if f.is_file() and f.name.endswith('.js') and not f.name == '_example.js' ] mode = ciu_client.ciu_info()['imode'] log.info("confirm.html - ssid {0}, mode {1}".format(ssid, mode)) return render_template("confirm.html", ssid=ssid, encrypted=encrypted, ssid_encoded=ssid_encoded, mode=mode, is_8021x=is_8021x, ias_login_scripts=ias_login_scripts)
def access_points(self): global apcache, cachetime if time.time() - cachetime > 5: cachetime = time.time() # keep anyone else from processing aps = iwscan.candidates() aps = [x for x in aps if x['ssid'] != states.hotspot_name] apcache = aps # set a timeout, if we got something if len(apcache): cachetime = time.time() # cache time actually starts now else: cachetime = 0 return apcache
def get_candidate_connections(device): candidates = [] for conn in get_all_connections(): settings = conn.GetSettings() ssid = get_ssid_from_connection(conn) try: if ssid \ and settings['connection']['type'] == '802-11-wireless' \ and settings['802-11-wireless']['mode'] == 'infrastructure': candidates.append(ssid) except KeyError: log.debug("Unexpected connection format for %s" % ssid) points = [x.Ssid for x in get_access_points(device)] iwpoints = [x['ssid'] for x in iwscan.candidates()] return list(set(candidates) & (set(points) | set(iwpoints)))