-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenumerate_sys.py
More file actions
42 lines (25 loc) · 763 Bytes
/
enumerate_sys.py
File metadata and controls
42 lines (25 loc) · 763 Bytes
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
from pathlib import Path
def list_files_recursive(directory):
files = []
for path in Path(directory).rglob("*"):
if path.is_file():
files.append(path)
return files
def get_data(filename: str) -> str:
try:
data = ""
with open(filename) as f:
data = f.read()
return data
except Exception:
print(f"Could not read {filename}")
return ""
if __name__ == "__main__":
directory = "/sys/devices/virtual/dmi/"
data = dict()
files = list_files_recursive(directory)
for file in files:
file_data = get_data(str(file))
data[str(file)] = file_data
for k in data.keys():
print(f"{k} -> {data[k].strip()}")