[TCT][Tool][Non-ACR] Remove complete module support added 10/310910/2
authorUtkarsh Tiwari <utk.tiwari@samsung.com>
Thu, 9 May 2024 10:35:26 +0000 (16:05 +0530)
committerUtkarsh Tiwari <utk.tiwari@samsung.com>
Thu, 9 May 2024 11:06:35 +0000 (16:36 +0530)
Change-Id: Ia067b50ac60467721f06feea53c77aa86ec521aa
Signed-off-by: Utkarsh Tiwari <utk.tiwari@samsung.com>
tool/TC_Assistant_Tool/config.py [new file with mode: 0644]
tool/TC_Assistant_Tool/data_TCT.json
tool/TC_Assistant_Tool/execute_tc.py
tool/TC_Assistant_Tool/get_current_dir_path.py
tool/TC_Assistant_Tool/new_module_addition.py
tool/TC_Assistant_Tool/remove_deprecated_api.py
tool/TC_Assistant_Tool/tct_assistance.py

diff --git a/tool/TC_Assistant_Tool/config.py b/tool/TC_Assistant_Tool/config.py
new file mode 100644 (file)
index 0000000..06ec3a4
--- /dev/null
@@ -0,0 +1,3 @@
+#enter system password in this file before running tool to enable use of sudo
+
+SYSTEM_PASSWORD = ""
\ No newline at end of file
index 44fc33e10f07cfe838b4523274d6337441ea3b15..211ddcddbe679ac5613d205d99c7d86d3e23be3c 100644 (file)
       "tag": "removeapi",\r
       "patterns": ["Remove Deprecated APIs"],\r
       "responses": [\r
-        "Please enter the list of deprecated APIs which you want to be removed in the format of DELETE: API_NAME_1, API_NAME_2, API_NAME_3, etc. \n\n[ To navigate, please type 'Back' ]"\r
+        "Please enter the list of deprecated APIs which you want to be removed in the format of DELETE: API_NAME_1, API_NAME_2, API_NAME_3, etc. \n\nOR\n\nIf full module is to be deleted then type: DELETE: full_module\n\n[ To navigate, please type 'Back' ]"\r
       ]\r
     },\r
     {\r
index dd708c70834a2b40c37205296c4c9eb188f5f6f2..443047b1c29071aa11d4b86974eee71248f9dc33 100644 (file)
@@ -1,6 +1,7 @@
 import subprocess
 import re
 from get_current_dir_path import *
+import config
 
 # Function opens tct-mgr tool for to run tc
 
@@ -12,9 +13,9 @@ def open_tct_mgr():
 def tpk_build_install(PROCESS, TYPE_OF_TCs, MODULE_NAME, DEVICE_TYPE, ARCHITECTURE_TYPE):
     lst = []
     CURRENT_PATH = get_current_dir_path()
-    command = f"echo 'Samsung@123' | sudo -S ./tpkbuild {PROCESS} {TYPE_OF_TCs} {MODULE_NAME} {DEVICE_TYPE} {ARCHITECTURE_TYPE} &"
+    command = f"echo {config.SYSTEM_PASSWORD} | sudo -S ./tpkbuild {PROCESS} {TYPE_OF_TCs} {MODULE_NAME} {DEVICE_TYPE} {ARCHITECTURE_TYPE} &"
     process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True, cwd=CURRENT_PATH)
-    proc_stdout = process.communicate(input='Samsung@123')[0]
+    proc_stdout = process.communicate(input=config.SYSTEM_PASSWORD)[0]
     for line in proc_stdout.decode().split('\n'):
         lst.append(line)
     return "\n".join(lst)
index 58d3235e324cb686c9bdef445a97c606177fbce3..eba0658d4517989d548025abd6b32f413bf87249 100644 (file)
@@ -1,11 +1,12 @@
 import subprocess
 import re
+import config
 
 def get_current_dir_path():
     lst = []
     command = f"pwd"
     process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True)
-    proc_stdout = process.communicate(input='Samsung@123')[0]
+    proc_stdout = process.communicate(input=config.SYSTEM_PASSWORD)[0]
     for line in proc_stdout.decode().split('\n'):
         lst.append(line)
     path = "\n".join(lst)
@@ -19,7 +20,7 @@ def get_current_dir_path_for_image():
     lst = []
     command = f"pwd"
     process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True)
-    proc_stdout = process.communicate(input='Samsung@123')[0]
+    proc_stdout = process.communicate(input=config.SYSTEM_PASSWORD)[0]
     for line in proc_stdout.decode().split('\n'):
         lst.append(line)
     path = "".join(lst)
index 3ab1f0325c902f56726487861ea8a1b7fffa90c4..ec057cc6778b652999e7acb7b1be495b32f94cdb 100644 (file)
@@ -1,20 +1,21 @@
 from get_current_dir_path import *
 import subprocess
+import config
 
 def provide_permission(MODULE_NAME, CURRENT_PATH):
     CURRENT_PATH = CURRENT_PATH + "/src/utc"
-    command = f"echo 'Samsung@123' | sudo -S chmod -R 777 {MODULE_NAME} &"
+    command = f"echo {config.SYSTEM_PASSWORD} | sudo -S chmod -R 777 {MODULE_NAME} &"
     process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True, cwd=CURRENT_PATH)
-    process.communicate(input='Samsung@123')[0]
+    process.communicate(input=config.SYSTEM_PASSWORD)[0]
 
 
 
 def new_module_addition(MODULE_NAME, TYPE_OF_TCs):
     lst = []
     CURRENT_PATH = get_current_dir_path()
-    command = f"echo 'Samsung@123' | sudo -S ./tpkbuild addmod {TYPE_OF_TCs} {MODULE_NAME} &"
+    command = f"echo {config.SYSTEM_PASSWORD} | sudo -S ./tpkbuild addmod {TYPE_OF_TCs} {MODULE_NAME} &"
     process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True, cwd=CURRENT_PATH)
-    proc_stdout = process.communicate(input='Samsung@123')[0]
+    proc_stdout = process.communicate(input=config.SYSTEM_PASSWORD)[0]
     for line in proc_stdout.decode().split('\n'):
         lst.append(line)
     provide_permission(MODULE_NAME, CURRENT_PATH)
index 0c205fa003a40bb0a79383b32bd42457ee4ab30f..2e70822cc9da2de106821ab4336ae852929e61b4 100644 (file)
@@ -1,4 +1,13 @@
 from list_module_files import *
+from get_current_dir_path import *
+
+
+def remove_complete_module(MODULE_NAME):
+    CURRENT_PATH = get_current_dir_path()
+    command = f"echo {config.SYSTEM_PASSWORD} | sudo ./tpkbuild rmmod utc {MODULE_NAME}&"
+    process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True, cwd=CURRENT_PATH)
+    proc_stdout = process.communicate(input=config.SYSTEM_PASSWORD)[0]
+
 
 def delete_tc_from_all_c_files(REMOVE_TC_LIST, MODULE_NAME, CURR_C_FILE, TC_DIR_PATH):
     TC_DIR_PATH_FINAL = f"{TC_DIR_PATH}/{MODULE_NAME}/{CURR_C_FILE}"
index fb83e3a38db02fa417dfd1a361c7581459e32bd4..efd4c536e4b909df27433699936eb03dcb563caa 100644 (file)
@@ -503,7 +503,7 @@ def get_response(message):
                 if module_name_suggested == True:\r
                     last_stage_index = 1\r
                     if previous_intent == "removeapi":\r
-                        result = "Module name found" + "\n" + "Please enter the list of deprecated APIs which you want to be removed in the format of DELETE: API_NAME_1, API_NAME_2, API_NAME_3, etc.\n\n[ To navigate, please type 'Back' ]"\r
+                        result = "Module name found" + "\n" + "Please enter the list of deprecated APIs which you want to be removed in the format of DELETE: API_NAME_1, API_NAME_2, API_NAME_3, etc.\n\nOR\n\nIf full module is to be deleted then type: DELETE: full_module\n\n[ To navigate, please type 'Back' ]"\r
                         previous_intent = 'modulename'\r
                     else:\r
                         result = "Module name found" + "\n" + result\r
@@ -845,22 +845,27 @@ def get_response(message):
             MODULE_NAME = module_name.lower()\r
             CURRENT_PATH = get_current_dir_path()\r
             TC_DIR_PATH = CURRENT_PATH + r'src/utc/'\r
-            REMOVE_TC_LIST, NOT_FOUND_API_LIST = deprecated_api_removal(MODULE_NAME, remove_api_names, TC_DIR_PATH)\r
-            REMOVE_TC_LIST_NUMBERED = ""\r
-            NOT_FOUND_API_LIST_NUMBERED = ""\r
-            for i, item in enumerate(REMOVE_TC_LIST, start=1):\r
-                REMOVE_TC_LIST_NUMBERED += f"{i}. {item}" + "\n"\r
-            for i, item in enumerate(NOT_FOUND_API_LIST, start=1):\r
-                NOT_FOUND_API_LIST_NUMBERED += f"{i}. {item}" + "\n"\r
-\r
-            if len(REMOVE_TC_LIST) == 0:\r
-                result = "TCs not found for the below APIs (Please remove these not found TCs manually)\n\n" + f"{NOT_FOUND_API_LIST_NUMBERED}" + "\n\n[ To navigate, please type 'Back' ]"\r
-            elif len(REMOVE_TC_LIST) > 0 and len(NOT_FOUND_API_LIST) == 0:\r
-                result = "Above mentioned TCs will be removed. Please find TCs detail for these APIs as below:\n\n" + f"{REMOVE_TC_LIST_NUMBERED}" + "\n\nIf above TCs information is correct then type 'YES' to remove them otherwise 'NO'" + "\n\n[ To navigate, please type 'Back' ]"\r
-            elif len(REMOVE_TC_LIST) > 0 and len(NOT_FOUND_API_LIST) > 0:\r
-                result = "Above mentioned TCs will be removed. Please find TCs detail for these APIs as below:\n\n" + f"{REMOVE_TC_LIST_NUMBERED}" + "\n\nTCs not found for the below APIs (Please remove these not found TCs manually)\n\n" + f"{NOT_FOUND_API_LIST_NUMBERED}" + "\n\nIf above TCs information is correct then type 'YES' to remove them otherwise 'NO'" + "\n\n[ To navigate, please type 'Back' ]"\r
+            remove_api_names = remove_api_names.strip()\r
+            if remove_api_names == "full_module":\r
+                remove_complete_module(MODULE_NAME)\r
+                result = "Full module removed. \n\nType 'Exit' to close the tool."\r
             else:\r
-                result = "Above mentioned TCs will be removed. Please find TCs detail for these APIs as below:\n\n" + f"{REMOVE_TC_LIST_NUMBERED}" + "\n\nTCs not found for the below APIs (Please remove these not found TCs manually)\n\n" + f"{NOT_FOUND_API_LIST_NUMBERED}" + "\n\nIf above TCs information is correct then type 'YES' to remove them otherwise 'NO'" + "\n\n[ To navigate, please type 'Back' ]"\r
+                REMOVE_TC_LIST, NOT_FOUND_API_LIST = deprecated_api_removal(MODULE_NAME, remove_api_names, TC_DIR_PATH)\r
+                REMOVE_TC_LIST_NUMBERED = ""\r
+                NOT_FOUND_API_LIST_NUMBERED = ""\r
+                for i, item in enumerate(REMOVE_TC_LIST, start=1):\r
+                    REMOVE_TC_LIST_NUMBERED += f"{i}. {item}" + "\n"\r
+                for i, item in enumerate(NOT_FOUND_API_LIST, start=1):\r
+                    NOT_FOUND_API_LIST_NUMBERED += f"{i}. {item}" + "\n"\r
+\r
+                if len(REMOVE_TC_LIST) == 0:\r
+                    result = "TCs not found for the below APIs (Please remove these not found TCs manually)\n\n" + f"{NOT_FOUND_API_LIST_NUMBERED}" + "\n\n[ To navigate, please type 'Back' ]"\r
+                elif len(REMOVE_TC_LIST) > 0 and len(NOT_FOUND_API_LIST) == 0:\r
+                    result = "Above mentioned TCs will be removed. Please find TCs detail for these APIs as below:\n\n" + f"{REMOVE_TC_LIST_NUMBERED}" + "\n\nIf above TCs information is correct then type 'YES' to remove them otherwise 'NO'" + "\n\n[ To navigate, please type 'Back' ]"\r
+                elif len(REMOVE_TC_LIST) > 0 and len(NOT_FOUND_API_LIST) > 0:\r
+                    result = "Above mentioned TCs will be removed. Please find TCs detail for these APIs as below:\n\n" + f"{REMOVE_TC_LIST_NUMBERED}" + "\n\nTCs not found for the below APIs (Please remove these not found TCs manually)\n\n" + f"{NOT_FOUND_API_LIST_NUMBERED}" + "\n\nIf above TCs information is correct then type 'YES' to remove them otherwise 'NO'" + "\n\n[ To navigate, please type 'Back' ]"\r
+                else:\r
+                    result = "Above mentioned TCs will be removed. Please find TCs detail for these APIs as below:\n\n" + f"{REMOVE_TC_LIST_NUMBERED}" + "\n\nTCs not found for the below APIs (Please remove these not found TCs manually)\n\n" + f"{NOT_FOUND_API_LIST_NUMBERED}" + "\n\nIf above TCs information is correct then type 'YES' to remove them otherwise 'NO'" + "\n\n[ To navigate, please type 'Back' ]"\r
 \r
 \r
         elif intent == 'donotremove':\r