def record_login(address, timestamp=None): if not timestamp: timestamp = datetime.utcnow() if last_login(): uci.set(previous_login_ip, uci.get(last_login_ip)) uci.set(previous_login_timestamp, uci.get(last_login_timestamp)) uci.set(last_login_timestamp, timestamp.strftime('%Y-%m-%dT%H:%M:%S')) uci.set(last_login_ip, address) uci.commit("openwireless")
def record_login(address, timestamp = None): if not timestamp: timestamp = datetime.utcnow() if last_login(): uci.set(previous_login_ip, uci.get(last_login_ip)) uci.set(previous_login_timestamp, uci.get(last_login_timestamp)) uci.set(last_login_timestamp, timestamp.strftime('%Y-%m-%dT%H:%M:%S')) uci.set(last_login_ip, address) uci.commit("openwireless")
def enabled(index): return uci.get("wireless.@wifi-iface[%d].disabled" % index) != "1"
def _get_date(key): date_string = uci.get(key) return date_string and datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S')
def previous_login(): address = uci.get(previous_login_ip) timestamp = _get_date(previous_login_timestamp) return _build_login(address, timestamp)
def last_login(): address = uci.get(last_login_ip) timestamp = _get_date(last_login_timestamp) return _build_login(address, timestamp)