This repository has been archived by the owner on Jan 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18e75bc
commit 7152a67
Showing
4 changed files
with
61 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
def retract_lines(lines): | ||
for _ in range(lines): | ||
print('\033[1A\033[2K', end='', flush=True) | ||
|
||
def exit_and_retract(lines, status=0): | ||
retract_lines(lines) | ||
print('\nExiting...\n\033[2K') | ||
exit(status) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,50 @@ | ||
# Left here for a hash/shebang letter edit in a possible setup script I might make | ||
from colorama import Fore, Style, init | ||
import runpy, os | ||
import functions | ||
|
||
init() | ||
|
||
storm_processes = [ | ||
{'name': 'System Information', 'desc': 'Basic infomation about your system', 'path': 'sysinfo.py', 'colour': 'GREEN'}, | ||
{'name': 'Resource Monitor', 'desc': 'A basic ', 'path': 'monitor.py', 'colour': 'BLUE'}, | ||
{ | ||
"name": "System Information", | ||
"desc": "Basic infomation about your system", | ||
"path": "sysinfo.py", | ||
"colour": "GREEN", | ||
}, | ||
{ | ||
"name": "Resource Monitor", | ||
"desc": "A basic ", | ||
"path": "monitor.py", | ||
"colour": "BLUE", | ||
}, | ||
] | ||
color_map = { | ||
'BLACK': Fore.BLACK, | ||
'RED': Fore.RED, | ||
'GREEN': Fore.GREEN, | ||
'YELLOW': Fore.YELLOW, | ||
'BLUE': Fore.BLUE, | ||
'MAGENTA': Fore.MAGENTA, | ||
'CYAN': Fore.CYAN, | ||
'WHITE': Fore.WHITE, | ||
'RESET': Style.RESET_ALL | ||
"BLACK": Fore.LIGHTBLACK_EX, | ||
"RED": Fore.LIGHTRED_EX, | ||
"GREEN": Fore.LIGHTGREEN_EX, | ||
"YELLOW": Fore.LIGHTYELLOW_EX, | ||
"BLUE": Fore.LIGHTBLUE_EX, | ||
"MAGENTA": Fore.LIGHTMAGENTA_EX, | ||
"CYAN": Fore.LIGHTCYAN_EX, | ||
"WHITE": Fore.LIGHTWHITE_EX, | ||
"RESET": Style.RESET_ALL, | ||
} | ||
path = os.path.dirname(__file__) | ||
|
||
for index, process in enumerate(storm_processes): | ||
print(f"{color_map[process['colour']]}[{index}={process['name']}]{Style.RESET_ALL} {process['desc']}{Style.RESET_ALL}") | ||
print( | ||
f"{color_map[process['colour']]}[{index}={process['name']}]{Style.RESET_ALL} {process['desc']}{Style.RESET_ALL}" | ||
) | ||
|
||
try: | ||
choice = int(input('Please enter your choice:')) | ||
choice = int(input("Please enter your choice:")) | ||
except Exception as failure: | ||
print(f'Failure: {failure}') | ||
print(f"Failure: {failure}") | ||
exit(1) | ||
except KeyboardInterrupt: | ||
functions.exit_and_retract(2, 0) | ||
try: | ||
for _ in range(3): | ||
print('\033[1A\033[2K', end='', flush=True) | ||
functions.retract_lines(3) | ||
runpy.run_path(f'{path}/{storm_processes[choice]["path"]}') | ||
except Exception as failure: | ||
print(f'Failure: {failure}') | ||
print(f"Failure: {failure}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,30 @@ | ||
from colorama import Fore, Style, init | ||
from colorama import Fore, Style | ||
import psutil, time | ||
|
||
init() | ||
import functions | ||
|
||
def gb_calculation(value): | ||
return f"{value / (1024 ** 3):.2f}" | ||
|
||
def print_stats(cpu, ram, swap): | ||
print(Fore.YELLOW + "Processer Load: " + Style.RESET_ALL + f'{cpu}%', flush=True) | ||
print(Fore.MAGENTA + "Total RAM: " + Style.RESET_ALL + f"{gb_calculation(ram.total)} GB", flush=True) | ||
print(Fore.MAGENTA + "Available RAM: " + Style.RESET_ALL + f"{gb_calculation(ram.available)} GB", flush=True) | ||
print(Fore.MAGENTA + "Used RAM: " + Style.RESET_ALL + f"{gb_calculation(ram.used)} GB", flush=True) | ||
print(Fore.MAGENTA + "RAM usage percentage: " + Style.RESET_ALL + f'{ram.percent}%', flush=True) | ||
print(Fore.GREEN + "Total Swap: " + Style.RESET_ALL + f"{gb_calculation(swap.total)} GB") | ||
print(Fore.GREEN + "Used Swap: " + Style.RESET_ALL + f"{gb_calculation(swap.used)} GB") | ||
print(Fore.GREEN + "Free Swap: " + Style.RESET_ALL + f"{gb_calculation(swap.free)} GB") | ||
print(Fore.GREEN + "Swap usage percentage: " + Style.RESET_ALL + f"{swap.percent}%") | ||
|
||
try: | ||
psutil.cpu_percent(interval=1) | ||
while True: | ||
c = psutil.cpu_percent(interval=0) | ||
r = psutil.virtual_memory() | ||
s = psutil.swap_memory() | ||
print_stats(c, r, s) | ||
cpu = psutil.cpu_percent(interval=0) | ||
ram = psutil.virtual_memory() | ||
swap = psutil.swap_memory() | ||
print(Fore.LIGHTYELLOW_EX + "Processer Load: " + Style.RESET_ALL + f'{cpu}%', flush=True) | ||
print(Fore.LIGHTMAGENTA_EX + "Total RAM: " + Style.RESET_ALL + f"{gb_calculation(ram.total)} GB", flush=True) | ||
print(Fore.LIGHTMAGENTA_EX + "Available RAM: " + Style.RESET_ALL + f"{gb_calculation(ram.available)} GB", flush=True) | ||
print(Fore.LIGHTMAGENTA_EX + "Used RAM: " + Style.RESET_ALL + f"{gb_calculation(ram.used)} GB", flush=True) | ||
print(Fore.LIGHTMAGENTA_EX + "RAM usage percentage: " + Style.RESET_ALL + f'{ram.percent}%', flush=True) | ||
print(Fore.LIGHTGREEN_EX + "Total Swap: " + Style.RESET_ALL + f"{gb_calculation(swap.total)} GB", flush=True) | ||
print(Fore.LIGHTGREEN_EX + "Used Swap: " + Style.RESET_ALL + f"{gb_calculation(swap.used)} GB", flush=True) | ||
print(Fore.LIGHTGREEN_EX + "Free Swap: " + Style.RESET_ALL + f"{gb_calculation(swap.free)} GB", flush=True) | ||
print(Fore.LIGHTGREEN_EX + "Swap usage percentage: " + Style.RESET_ALL + f"{swap.percent}%", flush=True) | ||
print("\nPress CMD+C or CTRL+C to exit", flush=True) | ||
time.sleep(1) | ||
for _ in range(9): | ||
print('\033[1A\033[2K', end='', flush=True) | ||
functions.retract_lines(11) | ||
except KeyboardInterrupt: | ||
for _ in range(9): | ||
print('\033[1A\033[2K', end='', flush=True) | ||
print("\nExiting...") | ||
functions.exit_and_retract(11) | ||
except Exception as e: | ||
print(f"Exception has occured: {e}") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters