Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
True # https://pyautogui.readthedocs.io/en/latest/
from fileinput import filename
import os, os.path, sys, time, inspect, subprocess
from turtle import right

from Framework.Utilities import CommonUtil, FileUtilities as FL
from Framework.Utilities.decorators import logger
Expand All @@ -36,7 +35,6 @@
from Framework.Utilities import ConfigModule
import traceback
import platform
import easyocr
from thefuzz import fuzz
import threading
from pathlib import Path
Expand Down Expand Up @@ -1255,16 +1253,87 @@ def keystroke_for_element(data_set):

reader = None

def install_easyocr():
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME

# get the OS
pltform = platform.system()

#check easyocr installment in Windows
if pltform == "Windows":
pip_command = ['pip', 'list']
easyocr_search_command = ['findstr', 'easyocr']
pip_process = subprocess.Popen(pip_command, stdout=subprocess.PIPE)
search_process = subprocess.Popen(easyocr_search_command, stdin=pip_process.stdout, stdout=subprocess.PIPE,text=True)

is_easyocr, _ = search_process.communicate()

if is_easyocr:
CommonUtil.ExecLog(
sModuleInfo,
"Easyocr is already installed",
5,
)
else:
CommonUtil.ExecLog(
sModuleInfo,
"Installing Easyocr",
5,
)
try:
result = subprocess.run(
['pip', 'install', '--trusted-host', 'pypi.org', '--trusted-host', 'files.pythonhosted.org', 'easyocr'],
check=True,
text=True,
capture_output=True
)
CommonUtil.ExecLog(sModuleInfo,f"{result.stdout}",5)
except subprocess.CalledProcessError as e:
print(f"Error occurred: {e.stderr}")
else:
pip_command = ['pip3', 'list']
easyocr_search_command = ['grep', 'easyocr']
pip_process = subprocess.Popen(pip_command, stdout=subprocess.PIPE)
search_process = subprocess.Popen(easyocr_search_command, stdin=pip_process.stdout, stdout=subprocess.PIPE,text=True)

is_easyocr, _ = search_process.communicate()

if is_easyocr:
CommonUtil.ExecLog(
sModuleInfo,
"Easyocr is already installed",
5,
)
else:
CommonUtil.ExecLog(
sModuleInfo,
"Installing Easyocr",
5,
)
try:
result = subprocess.run(
['pip3', 'install', '--trusted-host', 'pypi.org', '--trusted-host', 'files.pythonhosted.org', 'easyocr'],
check=True,
text=True,
capture_output=True
)
CommonUtil.ExecLog(sModuleInfo,f"{result.stdout}",5)
except subprocess.CalledProcessError as e:
print(f"Error occurred: {e.stderr}")



# initialize the OCR
def get_easyocr_reader():
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
install_easyocr()
import easyocr
global reader
if not reader:
CommonUtil.ExecLog(sModuleInfo, "Initializing EasyOCR reader...", 1)
reader = easyocr.Reader(['en'])
else:
CommonUtil.ExecLog(sModuleInfo, "EasyOCR reader already initialized.", 1)
return reader

# create a list of texts
def get_only_text(data:tuple):
Expand Down
1 change: 1 addition & 0 deletions requirements-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ configobj
jinja2
pandas
pyperclip
thefuzz
backports-datetime-fromisoformat; python_version < '3.11'
3 changes: 2 additions & 1 deletion requirements-mac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ configobj
jinja2
pandas
pyperclip
backports-datetime-fromisoformat; python_version < '3.11'
backports-datetime-fromisoformat; python_version < '3.11'
thefuzz
3 changes: 2 additions & 1 deletion requirements-win.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ configobj
jinja2
pandas
pyperclip
backports-datetime-fromisoformat; python_version < '3.11'
backports-datetime-fromisoformat; python_version < '3.11'
thefuzz