|
33 | 33 | import PIL |
34 | 34 | from PIL import Image, ImageGrab |
35 | 35 |
|
36 | | -import psutil |
37 | | - |
38 | 36 |
|
39 | 37 | python_folder = [] |
40 | 38 | for location in subprocess.getoutput("where python").split("\n"): |
|
44 | 42 | python_location = "" if len(python_folder) == 0 else "by going to {}".format(python_folder[0].split("Python")[0] + "Python") |
45 | 43 | except: |
46 | 44 | python_location = "" |
47 | | -if not 3.5 <= float(sys.version.split(" ")[0][0:3]) <= 3.8: |
| 45 | + |
| 46 | +full_python_version = sys.version.split(" ")[0] |
| 47 | +python_sub_version = re.search(r'\b\d+\.(\d+)\.\d+\b', full_python_version) |
| 48 | + |
| 49 | +if not 7 <= int(python_sub_version.group(1)) <= 11: |
48 | 50 | error_msg = "You have the wrong Python version or bit" \ |
| 51 | + +"\nThe Python version should be 3.7 <= x <= 3.11"\ |
49 | 52 | + "\nFollow this procedure" \ |
50 | 53 | + "\n1.Go to settings, then go to Apps and in search box type python and uninstall all python related things" \ |
51 | 54 | + "\n2.Delete your Python folder" \ |
52 | 55 | + python_location \ |
53 | | - + "\n3.Go to this link and download python https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe" \ |
| 56 | + + "\n3.Go to this link and download python https://www.python.org/ftp/python/3.11.4/python-3.11.4-amd64.exe" \ |
54 | 57 | + "\n4.During installation, give uncheck 'for all user' and check 'Add Python to Path'. This is very important." \ |
55 | 58 | + "\n5.Relaunch zeuz node_cli.py" |
56 | 59 | CommonUtil.ExecLog("", error_msg, 3) |
@@ -995,6 +998,90 @@ def install_ocr(): |
995 | 998 | def image_search(step_data_set): |
996 | 999 | install_ocr() |
997 | 1000 | sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME |
| 1001 | + |
| 1002 | + try: |
| 1003 | + # steps to install the pytesseract module |
| 1004 | + pip_command = ['pip', 'list'] |
| 1005 | + pytesseract_search_command = ['findstr', 'pytesseract'] |
| 1006 | + |
| 1007 | + pip_process = subprocess.Popen(pip_command, stdout=subprocess.PIPE) |
| 1008 | + search_process = subprocess.Popen(pytesseract_search_command, stdin=pip_process.stdout, stdout=subprocess.PIPE, text=True) |
| 1009 | + |
| 1010 | + is_pytesseract,_ = search_process.communicate() |
| 1011 | + |
| 1012 | + if is_pytesseract: |
| 1013 | + CommonUtil.ExecLog( |
| 1014 | + sModuleInfo, |
| 1015 | + "Pytesseractt is already installed", |
| 1016 | + 5, |
| 1017 | + ) |
| 1018 | + else: |
| 1019 | + CommonUtil.ExecLog( |
| 1020 | + sModuleInfo, |
| 1021 | + "Installing Pytesseract", |
| 1022 | + 5, |
| 1023 | + ) |
| 1024 | + os.system('echo y | pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pytesseract') |
| 1025 | + except: |
| 1026 | + CommonUtil.ExecLog( |
| 1027 | + sModuleInfo, |
| 1028 | + "Could not install the Pytesseract module", |
| 1029 | + 3, |
| 1030 | + ) |
| 1031 | + |
| 1032 | + try: |
| 1033 | + # steps to install pytesseract executable file |
| 1034 | + reg_query_cmd = ['reg', 'query', r'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', '/s'] |
| 1035 | + findstr_cmd = ['findstr', '/B', '.*DisplayName'] |
| 1036 | + tesseract_cmd = ['findstr', 'Tesseract-OCR'] |
| 1037 | + |
| 1038 | + reg_query_process = subprocess.Popen(reg_query_cmd, stdout=subprocess.PIPE) |
| 1039 | + findstr_process = subprocess.Popen(findstr_cmd, stdin=reg_query_process.stdout, stdout=subprocess.PIPE) |
| 1040 | + tesseract_process = subprocess.Popen(tesseract_cmd, stdin=findstr_process.stdout, stdout=subprocess.PIPE, text=True) |
| 1041 | + |
| 1042 | + is_pytesseract_exe, _ = tesseract_process.communicate() |
| 1043 | + |
| 1044 | + if is_pytesseract_exe: |
| 1045 | + CommonUtil.ExecLog( |
| 1046 | + sModuleInfo, |
| 1047 | + "Pytesseract executable file is alreday installed", |
| 1048 | + 5, |
| 1049 | + ) |
| 1050 | + else: |
| 1051 | + CommonUtil.ExecLog( |
| 1052 | + sModuleInfo, |
| 1053 | + "Starting installation of Pytesseract executable file", |
| 1054 | + 5, |
| 1055 | + ) |
| 1056 | + install_process = subprocess.Popen(['winget', 'install', 'Tesseract-OCR - open source OCR engine'], text=True) |
| 1057 | + stdout, stderr = install_process.communicate() |
| 1058 | + if stdout is not None: |
| 1059 | + CommonUtil.ExecLog(sModuleInfo, f"The standard output for winget install Tesseract-OCR {stdout}", 5) |
| 1060 | + if stderr is not None: |
| 1061 | + CommonUtil.ExecLog( |
| 1062 | + sModuleInfo, |
| 1063 | + f"The standard error for winget install Tesseract-OCR {stderr}", |
| 1064 | + 5, |
| 1065 | + ) |
| 1066 | + else: |
| 1067 | + CommonUtil.ExecLog(sModuleInfo, f"Tesseract installation is complete!", 5) |
| 1068 | + |
| 1069 | + CommonUtil.ExecLog( |
| 1070 | + sModuleInfo, |
| 1071 | + "Setting up the environment variable for Tesseract OCR", |
| 1072 | + 5, |
| 1073 | + ) |
| 1074 | + |
| 1075 | + # Todo: No need to add this in PATH |
| 1076 | + ocr_path = r"C:\Program Files\Tesseract-OCR" |
| 1077 | + os.environ['PATH'] += ';' + ocr_path |
| 1078 | + except: |
| 1079 | + CommonUtil.ExecLog( |
| 1080 | + sModuleInfo, |
| 1081 | + "Could not install the Pytesseract executable file", |
| 1082 | + 3, |
| 1083 | + ) |
| 1084 | + |
998 | 1085 | try: |
999 | 1086 | file_name = "" |
1000 | 1087 | resolution = "" |
@@ -2159,7 +2246,7 @@ def Keystroke_For_Element(data_set): |
2159 | 2246 | keystroke_value = right.strip().lower() # Store keystroke |
2160 | 2247 | elif left == "keystroke chars": |
2161 | 2248 | keystroke_char = right |
2162 | | - if "parameter"in mid.lower(): |
| 2249 | + if "optional parameter"in mid.lower(): |
2163 | 2250 | if left == "method": |
2164 | 2251 | method_name= right.lower() |
2165 | 2252 |
|
|
0 commit comments