check for missing depends

This commit is contained in:
WhatDidYouExpect 2025-06-27 19:45:44 +02:00
parent 04b0144281
commit d03fa25c88
3 changed files with 27 additions and 11 deletions

23
bot.py
View file

@ -6,6 +6,16 @@ import random
import shutil import shutil
import traceback import traceback
import subprocess import subprocess
from modules.globalvars import *
from modules.prestartchecks import start_checks
# Print splash text and check for updates
print(splashtext) # Print splash text (from modules/globalvars.py)
start_checks()
import requests import requests
import psutil import psutil
@ -19,22 +29,19 @@ from nltk.data import find
from nltk import download from nltk import download
from better_profanity import profanity from better_profanity import profanity
from modules.globalvars import *
from discord.ext import commands, tasks
from discord import app_commands
from modules.central import ping_server from modules.central import ping_server
from modules.translations import * from modules.translations import *
from modules.markovmemory import * from modules.markovmemory import *
from modules.version import * from modules.version import *
from modules.sentenceprocessing import * from modules.sentenceprocessing import *
from modules.prestartchecks import start_checks
from modules.unhandledexception import handle_exception from modules.unhandledexception import handle_exception
from modules.image import gen_image from modules.image import gen_image
from discord.ext import commands, tasks
from discord import app_commands
sys.excepthook = handle_exception
# Print splash text and check for updates sys.excepthook = handle_exception
print(splashtext) # Print splash text (from modules/globalvars.py)
start_checks()
check_for_update() # Check for updates (from modules/version.py) check_for_update() # Check for updates (from modules/version.py)
launched = False launched = False

View file

@ -40,5 +40,5 @@ song = os.getenv("song")
arch = platform.machine() arch = platform.machine()
slash_commands_enabled = False slash_commands_enabled = False
latest_version = "0.0.0" latest_version = "0.0.0"
local_version = "1.0.0" local_version = "1.0.1"
os.environ['gooberlocal_version'] = local_version os.environ['gooberlocal_version'] = local_version

View file

@ -1,10 +1,15 @@
import time import time
import os import os
import psutil
import sys import sys
import subprocess import subprocess
import ast import ast
psutilavaliable = True
try:
import requests import requests
import psutil
except ImportError:
psutilavaliable = False
print("Missing Requests! and Psutil!")
import re import re
import importlib.metadata import importlib.metadata
@ -141,6 +146,8 @@ def check_latency():
print(f"{RED}Error running ping: {e}{RESET}") print(f"{RED}Error running ping: {e}{RESET}")
def check_memory(): def check_memory():
if psutilavaliable == False:
return
try: try:
memory_info = psutil.virtual_memory() memory_info = psutil.virtual_memory()
total_memory = memory_info.total / (1024 ** 3) total_memory = memory_info.total / (1024 ** 3)
@ -160,6 +167,8 @@ def check_memory():
print("psutil is not installed. Memory check skipped.") print("psutil is not installed. Memory check skipped.")
def check_cpu(): def check_cpu():
if psutilavaliable == False:
return
print("Measuring CPU usage per core...") print("Measuring CPU usage per core...")
cpu_per_core = psutil.cpu_percent(interval=1, percpu=True) cpu_per_core = psutil.cpu_percent(interval=1, percpu=True)
for idx, core_usage in enumerate(cpu_per_core): for idx, core_usage in enumerate(cpu_per_core):