|
1 | 1 | import os |
2 | 2 | import subprocess |
3 | 3 | import sys |
4 | | - |
| 4 | +import logging |
| 5 | +import platform |
| 6 | +import shutil |
| 7 | +from datetime import datetime |
| 8 | + |
5 | 9 | kernelState = None |
6 | 10 |
|
7 | | -print("SkyOS v2.7 bugfix + app update") |
8 | | -print("This device is running SkyOS") |
9 | | -print("/bios/bios.py") |
10 | | -print(" ^ BIOS is running here") |
| 11 | +logging.basicConfig(filename='bios_log.txt', level=logging.INFO) |
| 12 | + |
| 13 | +def log_and_print(message): |
| 14 | + logging.info(message) |
| 15 | + print(message) |
| 16 | + |
| 17 | +def display_system_info(): |
| 18 | + log_and_print(f"System Info - Date/Time: {datetime.now()}") |
| 19 | + log_and_print(f"System Info - OS: {platform.system()} {platform.release()}") |
| 20 | + total, used, free = shutil.disk_usage("/") |
| 21 | + log_and_print(f"System Info - Disk space: {free // (2**30)} GB free") |
11 | 22 |
|
12 | 23 | def main(): |
| 24 | + display_system_info() |
| 25 | + |
13 | 26 | while True: |
14 | 27 | answer = input("exit? (yes/no): ").strip().lower() |
15 | 28 | if answer == "no": |
16 | | - print("SkyOS v2.7") |
17 | | - print("This device is running SkyOS") |
18 | | - print("/bios/bios.py/") |
19 | | - print(" ^ BIOS is running here") |
| 29 | + log_and_print("SkyOS v2.7") |
| 30 | + log_and_print("This device is running SkyOS") |
| 31 | + log_and_print("/bios/bios.py/") |
| 32 | + log_and_print(" ^ BIOS is running here") |
20 | 33 | elif answer == "yes": |
21 | | - # Path to the kernel script in the KERNEL folder |
22 | 34 | kernel_script = os.path.join(os.getcwd(), 'KERNEL', 'kernel.py') |
23 | 35 |
|
24 | | - # Check if the kernel script exists before trying to run it |
25 | 36 | if os.path.isfile(kernel_script): |
26 | 37 | try: |
27 | | - # Run the kernel script as a subprocess |
28 | 38 | subprocess.run([sys.executable, kernel_script], check=True) |
29 | 39 | except subprocess.CalledProcessError as e: |
30 | | - print(f"Error executing the kernel script: {e}") |
| 40 | + log_and_print(f"Error executing the kernel script: {e}") |
31 | 41 | except Exception as e: |
32 | | - print(f"An unexpected error occurred: {e}") |
| 42 | + log_and_print(f"An unexpected error occurred: {e}") |
33 | 43 | else: |
34 | | - print("sucsess!!!!!") |
| 44 | + log_and_print("Success!") |
35 | 45 | kernelState = "gone" |
36 | | - break # Exit the loop after trying to run the kernel script |
| 46 | + break |
37 | 47 | else: |
38 | | - print("Invalid input. Please type 'yes' or 'no'.") |
39 | | -if kernelState == "gone": |
40 | | - print("The skyOS kernel is missing. Please reinstall skyOS or, replace the kernel script.") |
| 48 | + log_and_print("Invalid input. Please type 'yes' or 'no'.") |
| 49 | + |
| 50 | + if kernelState == "gone": |
| 51 | + log_and_print("The SkyOS kernel is missing. Please reinstall SkyOS or replace the kernel script.") |
41 | 52 |
|
42 | 53 | if __name__ == "__main__": |
43 | 54 | main() |
0 commit comments