MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / get_ai_status

Function get_ai_status

webapp_modern.py:19012–19058  ·  view source on GitHub ↗

Get AI service status and configuration

()

Source from the content-addressed store, hash-verified

19010 fp = os.path.join(root, f)
19011 try:
19012 mtime = os.path.getmtime(fp)
19013 if mtime > latest_mtime:
19014 latest_mtime = mtime
19015 file_count += 1
19016 entries.append(fp)
19017 except OSError:
19018 pass
19019 flags[flag] = bool(entries)
19020
19021 if latest_mtime:
19022 import datetime as _dt
19023 last_seen = _dt.datetime.fromtimestamp(latest_mtime).strftime('%Y-%m-%d %H:%M')
19024 else:
19025 last_seen = ''
19026
19027 return {**flags, 'file_count': file_count, 'last_seen': last_seen}
19028
19029
19030@app.route('/api/networks/<slug>/files')
19031def get_network_files(slug):
19032 """Return a flat list of files stored under a specific network's directory."""
19033 try:
19034 # Validate slug
19035 if not slug or not all(c.isalnum() or c == '_' for c in slug):
19036 return jsonify({'success': False, 'error': 'Invalid network slug'}), 400
19037
19038 networks_dir = _get_networks_dir()
19039 network_dir = os.path.join(networks_dir, slug)
19040
19041 if not os.path.isdir(network_dir):
19042 return jsonify({'success': False, 'error': 'Network not found'}), 404
19043
19044 # Read human-readable SSID
19045 ssid = slug
19046 ssid_file = os.path.join(network_dir, 'ssid.txt')
19047 if os.path.exists(ssid_file):
19048 try:
19049 with open(ssid_file, 'r', encoding='utf-8') as _f:
19050 ssid = _f.read().strip() or slug
19051 except IOError:
19052 pass
19053
19054 # Categories to expose and their virtual path prefixes
19055 categories = {
19056 'data_stolen': os.path.join(network_dir, 'loot', 'data_stolen'),
19057 'credentials': os.path.join(network_dir, 'loot', 'credentials'),
19058 'vulnerabilities': os.path.join(network_dir, 'output', 'vulnerabilities'),
19059 'scan_results': os.path.join(network_dir, 'output', 'scan_results'),
19060 }
19061

Callers

nothing calls this directly

Calls 5

infoMethod · 0.80
initialize_ai_serviceMethod · 0.80
errorMethod · 0.80
getMethod · 0.45
is_enabledMethod · 0.45

Tested by

no test coverage detected