-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkyNP_Functions_Index.py
More file actions
267 lines (234 loc) · 11.1 KB
/
SkyNP_Functions_Index.py
File metadata and controls
267 lines (234 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import os, hashlib, sys, builtins
from datetime import datetime
import pandas as pd
command_reference_table = None
command_registry = None
# Define function for SkyShowIndex - COM100
def SkyShowIndex(base_path="/mnt/data", depth=2):
file_tree = []
def walk_dir(path, current_depth=0):
if current_depth > depth:
return
try:
with os.scandir(path) as it:
for entry in it:
info = {
"name": entry.name,
"path": entry.path,
"type": "DIR" if entry.is_dir() else "FILE",
"size_kb": os.path.getsize(entry.path) // 1024 if entry.is_file() else "",
"modified": datetime.fromtimestamp(entry.stat().st_mtime).strftime("%Y-%m-%d %H:%M:%S"),
"depth": current_depth
}
file_tree.append(info)
if entry.is_dir():
walk_dir(entry.path, current_depth + 1)
except Exception as e:
file_tree.append({
"name": f"[ERROR accessing: {path}]",
"path": path,
"type": "ERROR",
"size_kb": "",
"modified": "",
"depth": current_depth
})
walk_dir(base_path)
def SkyShowMntDirectory(base_path="/mnt/data"):
"""
Displays all files and folders under /mnt/data recursively,
including relative paths, file sizes (KB), and type.
"""
import os
import pandas as pd
entries = []
for root, dirs, files in os.walk(base_path):
for name in files:
path = os.path.join(root, name)
rel_path = os.path.relpath(path, base_path)
try:
size_kb = round(os.path.getsize(path) / 1024, 2)
except:
size_kb = None
entries.append({
"Path": rel_path,
"Size (KB)": size_kb,
"Type": "File"
})
for name in dirs:
path = os.path.join(root, name)
rel_path = os.path.relpath(path, base_path)
entries.append({
"Path": rel_path + "/",
"Size (KB)": None,
"Type": "Folder"
})
if not entries:
return "⚠️ No files or folders found under /mnt/data."
df = pd.DataFrame(entries)
return df.sort_values("Path").reset_index(drop=True)
def SkyFileAudit():
import os, datetime
path = "/mnt/data/"
try:
files = os.listdir(path)
if not files:
print("📂 No files currently in /mnt/data/")
return
print(f"📂 Files in /mnt/data/:")
for file in files:
fpath = os.path.join(path, file)
size = os.path.getsize(fpath)
modified = datetime.datetime.fromtimestamp(os.path.getmtime(fpath))
print(f" - {file} | Size: {size} bytes | Last Modified: {modified}")
except Exception as e:
print(f"❌ Failed to audit /mnt/data/: {e}")
def SkyVerifyFileState(filename):
fpath = f"/mnt/data/{filename}"
try:
with open(fpath, "rb") as f:
content = f.read()
hashval = hashlib.sha256(content).hexdigest()
print(f"✅ File '{filename}' exists. SHA256: {hashval}")
return hashval
except FileNotFoundError:
print(f"❌ File '{filename}' not found in /mnt/data/")
except Exception as e:
print(f"❌ Error verifying '{filename}': {e}")
def SkyPersistentHintLayer(filename):
import os
fpath = f"/mnt/data/{filename}"
try:
with open(fpath, "r", encoding="utf-8") as f:
f.readline()
print(f"🔁 Pinged '{filename}' to extend ephemeral retention.")
except Exception as e:
print(f"❌ Could not ping '{filename}': {e}")
# ════════════════════════════════════════════════════════════════
# 💡 SkySoftVaultIndex | Full Vault Map Viewer (recursive)
# ────────────────────────────────────────────────────────────────
# PURPOSE: Recursively lists all files and folders in /mnt/data/.
# STRATEGY: Walks the directory tree, maps structure with file sizes and timestamps.
# TEMPLATE: 📁 folder/
# └── 📄 file.ext (size, modified)
# ════════════════════════════════════════════════════════════════
def SkySoftVaultIndex():
global command_registry
if "command_registry" not in globals():
return "❌ command_registry not found."
if not command_registry:
return "⚠️ command_registry is empty."
data = []
for alias, func in command_registry.items():
if not callable(func):
continue
data.append({
"Alias": alias,
"Handler": getattr(func, "__name__", "Unknown"),
"Module": getattr(func, "__module__", "Unknown")
})
df = pd.DataFrame(data)
return df.sort_values("Alias").reset_index(drop=True)
# ════════════════════════════════════════════════════════════════
# 💡 SkySoftVaultBootIndex | Categorized Bootloader Integrity Map
# ────────────────────────────────────────────────────────────────
# PURPOSE: Lists and categorizes files inside the bootloader vault directory.
# STRATEGY: Scans /mnt/data/SkyNP_Bootloader/SkyNP_Bootloader,
# computes SHA256 hashes, and categorizes by type.
# TEMPLATE: 📁 Category
# └── 📄 filename.ext (SHA256: xxxxx...)
# ════════════════════════════════════════════════════════════════
def SkySoftVaultBootIndex():
global command_registry
if "command_registry" not in globals():
return "❌ command_registry not found."
if not command_registry:
return "⚠️ command_registry is empty."
import pandas as pd
data = []
for alias, func in command_registry.items():
if not callable(func):
continue
data.append({
"Alias": alias,
"Handler": getattr(func, "__name__", "Unknown"),
"Module": getattr(func, "__module__", "Unknown")
})
df = pd.DataFrame(data)
return df.sort_values("Alias").reset_index(drop=True)
# ═══════════════════════════════════════════════════════════════════════
# 💡 SkyShowCommands | Display Boot Manifest Command Reference Table
# PURPOSE: Reads the command_reference_table and prints all commands
# in a formatted table for visual inspection.
# STRATEGY: Relies on ignite-loaded global command_reference_table.
# ═══════════════════════════════════════════════════════════════════════
def SkyShowCommands():
ref_table = getattr(builtins, "command_reference_table", {})
print("📋 SkyShowCommands sees command_reference_table from builtins:", ref_table)
#print("📦 SkyShowCommands GLOBALS snapshot:", list(globals().keys()))
if not ref_table:
return "⚠️ command_reference_table is empty."
lines = ["📋 Available Command Aliases:\n"]
for alias, meta in sorted(ref_table.items()):
handler = meta.get("handler", "—")
module = meta.get("module", "—")
parameters = meta.get("parameters", "")
lines.append(f" {alias:<7} → {handler:<24} [{module}] {parameters}")
return "\n".join(lines)
"""
def SkyShowCommands():
ref_table = getattr(builtins, "command_reference_table", {})
print("📋 SkyShowCommands sees command_reference_table from builtins:", ref_table)
#print("📦 SkyShowCommands GLOBALS snapshot:", list(globals().keys()))
if not ref_table:
return "⚠️ command_reference_table is empty."
lines = ["📋 Available Command Aliases:\n"]
for alias, meta in sorted(ref_table.items()):
handler = meta.get("handler", "—")
module = meta.get("module", "—")
parameters = meta.get("parameters", "")
lines.append(f" {alias:<7} → {handler:<24} [{module}] {parameters}")
return "\n".join(lines)
"""
# ═════════════════════════════════════════════════════════════════════════════
# 💡 SkyShowGlobals | Runtime Global Variable Inventory
# ─────────────────────────────────────────────────────────────────────────────
# PURPOSE: Scans the active execution space and categorizes global
# variables by type: functions, modules, strings, lists, dicts, etc.
# STRATEGY: Uses introspection via `globals()` and prints sorted,
# grouped summaries for full developer/system awareness.
# ═════════════════════════════════════════════════════════════════════════════
def SkyShowGlobals():
import sys
global_vars = globals()
categorized = {
"functions": [],
"modules": [],
"strings": [],
"lists": [],
"dicts": [],
"other": []
}
for name, obj in global_vars.items():
if name.startswith('__') or name.startswith('_') or name in sys.modules:
continue
if callable(obj):
categorized["functions"].append(name)
elif isinstance(obj, type(sys)):
categorized["modules"].append(name)
elif isinstance(obj, str):
categorized["strings"].append(name)
elif isinstance(obj, list):
categorized["lists"].append(name)
elif isinstance(obj, dict):
categorized["dicts"].append(name)
else:
categorized["other"].append(name)
print("🧭 Sky Global Variable Inventory")
print("=" * 40)
for category, items in categorized.items():
if items:
print(f"\n🔹 {category.capitalize()} ({len(items)})")
print("-" * 30)
for var in sorted(items):
print(f" • {var}")
print("\n✅ Global visibility scan complete.")