-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall_module.py
More file actions
36 lines (29 loc) · 1.07 KB
/
uninstall_module.py
File metadata and controls
36 lines (29 loc) · 1.07 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
import os
import shutil
from colorful_outputs import print_in_green, print_in_red, print_in_yellow
from helper_functions import parse_module
from common_variables import C_CPP_MODULES_DLD_DIR
from init import remove_requirements
def uninstall(module_name: str):
'''
Uninstalls the module from the 'c_cpp_modules_dld' directory
Args:
module_name (str): The name of the module to uninstall
Returns:
None
Raises:
Exception: If there is an error while uninstalling the module
'''
version_exists = False
if("==" in module_name):
module_name, _ = parse_module(module_name)
module_path = os.path.join(C_CPP_MODULES_DLD_DIR, module_name)
if not os.path.isdir(module_path):
print_in_yellow(f"Warning: Module '{module_name}' not found in 'c_cpp_modules_dld'.")
return
try:
shutil.rmtree(module_path)
print_in_green(f"Successfully uninstalled {module_name}.")
remove_requirements(module_name)
except Exception as e:
print_in_red(f"Error uninstalling module: {e}")