MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / device_access

Function device_access

Scripts/ButSystem.py:10761–10837  ·  view source on GitHub ↗

Request admin approval to trust this device for auto-login. Works only for accounts without 2FA enabled.

()

Source from the content-addressed store, hash-verified

10759 prof = get_profile(me)
10760 except Exception:
10761 prof = {"nickname": me, "bio": "", "links": []}
10762 return jsonify({"ok": True, "me": me, "profile": {"nickname": prof.get("nickname") or me}})
10763
10764# ---------------------------
10765# Weather (Open-Meteo; no API key)
10766# ---------------------------
10767_WEATHER_CACHE: Dict[Tuple[float, float], Tuple[float, Dict[str, Any]]] = {}
10768_WEATHER_SEARCH_CACHE: Dict[Tuple[str, str], Tuple[float, List[Dict[str, Any]]]] = {}
10769_WEATHER_LOCK = threading.RLock()
10770_WEATHER_TTL = 10 * 60
10771_WEATHER_SEARCH_TTL = 60 * 60
10772
10773
10774def _weather_json(url: str, timeout: int = 12) -> Dict[str, Any]:
10775 req = urllib.request.Request(url, headers={"User-Agent": "ButSystem/Weather 1.0", "Accept": "application/json"})
10776 with urllib.request.urlopen(req, timeout=timeout) as response:
10777 raw = response.read(4 * 1024 * 1024)
10778 data = json.loads(raw.decode("utf-8", errors="replace"))
10779 if not isinstance(data, dict):
10780 raise ValueError("invalid weather response")
10781 return data
10782
10783
10784def _weather_code(code: Any, lang: str, is_day: bool = True) -> Tuple[str, str]:
10785 try:
10786 code = int(code)
10787 except Exception:
10788 code = -1
10789 labels_en = {
10790 0: "Clear sky", 1: "Mainly clear", 2: "Partly cloudy", 3: "Overcast",
10791 45: "Fog", 48: "Rime fog", 51: "Light drizzle", 53: "Drizzle", 55: "Heavy drizzle",
10792 56: "Freezing drizzle", 57: "Heavy freezing drizzle", 61: "Light rain", 63: "Rain", 65: "Heavy rain",
10793 66: "Freezing rain", 67: "Heavy freezing rain", 71: "Light snow", 73: "Snow", 75: "Heavy snow",
10794 77: "Snow grains", 80: "Light showers", 81: "Showers", 82: "Heavy showers",
10795 85: "Snow showers", 86: "Heavy snow showers", 95: "Thunderstorm", 96: "Thunderstorm with hail", 99: "Severe thunderstorm with hail",
10796 }
10797 labels_el = {
10798 0: "Καθαρός ουρανός", 1: "Κυρίως αίθριος", 2: "Λίγες νεφώσεις", 3: "Συννεφιά",
10799 45: "Ομίχλη", 48: "Παγωμένη ομίχλη", 51: "Ασθενής ψιχάλα", 53: "Ψιχάλα", 55: "Έντονη ψιχάλα",
10800 56: "Παγωμένη ψιχάλα", 57: "Έντονη παγωμένη ψιχάλα", 61: "Ασθενής βροχή", 63: "Βροχή", 65: "Ισχυρή βροχή",
10801 66: "Παγωμένη βροχή", 67: "Ισχυρή παγωμένη βροχή", 71: "Ασθενής χιονόπτωση", 73: "Χιονόπτωση", 75: "Ισχυρή χιονόπτωση",
10802 77: "Κόκκοι χιονιού", 80: "Ασθενείς μπόρες", 81: "Μπόρες", 82: "Ισχυρές μπόρες",
10803 85: "Μπόρες χιονιού", 86: "Ισχυρές μπόρες χιονιού", 95: "Καταιγίδα", 96: "Καταιγίδα με χαλάζι", 99: "Ισχυρή καταιγίδα με χαλάζι",
10804 }
10805 if code == 0:
10806 icon = "☀️" if is_day else "🌙"
10807 elif code in (1, 2):
10808 icon = "🌤️" if is_day else "☁️"
10809 elif code == 3:
10810 icon = "☁️"
10811 elif code in (45, 48):
10812 icon = "🌫️"
10813 elif code in (51, 53, 55, 56, 57):
10814 icon = "🌦️"
10815 elif code in (61, 63, 65, 66, 67, 80, 81, 82):
10816 icon = "🌧️"
10817 elif code in (71, 73, 75, 77, 85, 86):
10818 icon = "🌨️"

Callers

nothing calls this directly

Calls 8

is_logged_inFunction · 0.70
_admins_listFunction · 0.70
_Function · 0.70
_ensure_device_fp_cookieFunction · 0.70
user_2fa_enabledFunction · 0.70
db_connectFunction · 0.70
_client_ipFunction · 0.70
now_zFunction · 0.70

Tested by

no test coverage detected