Skip to content

Commit

Permalink
Merge pull request #1507 from totvs/release/v1.20.23
Browse files Browse the repository at this point in the history
Release/v1.20.23
  • Loading branch information
98llm authored Sep 6, 2024
2 parents ca5026d + 67aec98 commit 7887b70
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 99 deletions.
2 changes: 1 addition & 1 deletion scripts/install_package.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ taskkill /f /im chromedriver.exe
echo -------------------------
echo Installing project...
echo -------------------------
pip install -U dist/tir_framework-1.20.22.tar.gz
pip install -U dist/tir_framework-1.20.23.tar.gz
pause >nul | set/p = Press any key to exit ...
19 changes: 19 additions & 0 deletions tir/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,13 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):
:param position: Position which element is located. - **Default:** 1
:type position: int
> ⚠️ **Warning:**
> If there are a sequence of similar buttons. Example:
`self.oHelper.SetButton("Salvar")`
`self.oHelper.SetButton("Salvar")`
We recomend insert some wait of elements method between them, like WaitShow, WaitHide... etc.
This way you ensure the correct element be selected in correct screen.
Usage:
>>> # Calling the method to click on a regular button:
Expand Down Expand Up @@ -1488,6 +1495,18 @@ def CurrentWorkDirectory(self):

return os.chmod()

def StartSchedule(self):
"""Access de Schedule settings and Start all itens
"""
return self.__webapp.set_schedule(schedule_status=True)

def StopSchedule(self):
"""Access de Schedule settings and Stop all itens
"""
return self.__webapp.set_schedule(schedule_status=False)

class Apw():

def __init__(self, config_path=""):
Expand Down
41 changes: 26 additions & 15 deletions tir/technologies/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ def Start(self):
"""

start_program = '#inputStartProg, #selectStartProg'
driver_path = None

if self.config.appserver_service:
try:
Expand All @@ -1127,21 +1128,31 @@ def Start(self):
if self.config.headless:
chrome_options.add_argument('force-device-scale-factor=0.77')

try:
if self.config.chromedriver_auto_install:
if self.config.ssl_chrome_auto_install_disable:
os.environ['WDM_SSL_VERIFY'] = '0'
self.driver = webdriver.Chrome(options=chrome_options,
executable_path=ChromeDriverManager().install())
else:
if sys.platform == 'linux':
driver_path = Path(__file__).parent.resolve().joinpath('drivers', 'linux', 'chromedriver.exe')
elif sys.platform == 'win32':
driver_path = Path(__file__).parent.resolve().joinpath('drivers', 'windows', 'chromedriver.exe')
if self.config.chromedriver_auto_install:

counter = 1
while counter < 3:
try:
if self.config.ssl_chrome_auto_install_disable:
os.environ['WDM_SSL_VERIFY'] = '0'
driver_path = ChromeDriverManager().install()
break
except Exception as e:
logger().info("Trying get driver_path from ChromeDriverManager().Install")
time.sleep(30)
counter += 1
if counter > 2:
raise e

else:
if sys.platform == 'linux':
driver_path = Path(__file__).parent.resolve().joinpath('drivers', 'linux',
'chromedriver.exe')
elif sys.platform == 'win32':
driver_path = Path(__file__).parent.resolve().joinpath('drivers', 'windows',
'chromedriver.exe')

self.driver = webdriver.Chrome(options=chrome_options, executable_path=str(driver_path))
except Exception as e:
raise e
self.driver = webdriver.Chrome(options=chrome_options, executable_path=str(driver_path))

elif self.config.browser.lower() == "electron":
driver_path = os.path.join(os.path.dirname(__file__), r'drivers\\windows\\electron\\chromedriver.exe')
Expand Down Expand Up @@ -1297,7 +1308,7 @@ def webapp_shadowroot(self, shadow_root=True):
try:
current_ver = self.driver.execute_script("return app.VERSION")
if current_ver:
logger().debug(f'Webapp: {current_ver}')
logger().info(f'Webapp: {current_ver}')
current_ver = re.sub(r'\.(.*)', '', current_ver)
self.webapp_version = int(current_ver) >= 8
return self.webapp_version
Expand Down
15 changes: 11 additions & 4 deletions tir/technologies/core/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(self, language="pt-BR"):
self.success = languagepack["Success"]
self.procedure_install = languagepack["Procedure Install"]
self.procedure_uninstall = languagepack["Procedure Uninstall"]
self.schedule_menu = languagepack["Schedule Menu"]

self.messages = Messages(languagepack)

Expand Down Expand Up @@ -182,7 +183,8 @@ def get_language_pack(self, language):
"Code": "Code",
"Success": "Success",
"Procedure Install": "Install selected processes",
"Procedure Uninstall": "Remove selected processes"
"Procedure Uninstall": "Remove selected processes",
"Schedule Menu": "Settings > Schedule > Schedule"

}

Expand Down Expand Up @@ -276,7 +278,9 @@ def get_language_pack(self, language):
"Code": "Código",
"Success": "Sucessos",
"Procedure Install": "Instalar processos selecionados",
"Procedure Uninstall": "Remover processos selecionados"
"Procedure Uninstall": "Remover processos selecionados",
"Schedule Menu": "Ambiente > Schedule > Schedule"

}
spanish = {
"User": "Usuário",
Expand Down Expand Up @@ -368,7 +372,9 @@ def get_language_pack(self, language):
"Code": "Código",
"Success": "Sucessos",
"Procedure Install": "Instalar processos selecionados",
"Procedure Uninstall": "Remover processos selecionados"
"Procedure Uninstall": "Remover processos selecionados",
"Schedule Menu": "Entorno > Schedule > Schedule"

}
russian = {
"User": "Пользователь",
Expand Down Expand Up @@ -462,7 +468,8 @@ def get_language_pack(self, language):
"Code": "Код",
"Success": "успех",
"Procedure Install": "Установить выбранные процессы",
"Procedure Uninstall": "Удалить выбранные процессы"
"Procedure Uninstall": "Удалить выбранные процессы",
"Schedule Menu": "Settings > Schedule > Schedule"
}

if language.lower() == "en-us":
Expand Down
38 changes: 35 additions & 3 deletions tir/technologies/core/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ def checks_empty_line(self):

for row in range(0, len(self.table_rows)):
if self.table_rows[row][3] == '':
self.table_rows[row][3] = 'NO PROGRAM'
self.table_rows[row][3] = self.get_program_name()

if self.table_rows[row][10] == '':
self.table_rows[row][10] = '12.1.2310'
self.table_rows[row][10] = self.config.release if self.config.release else '12.1.2410'

if self.table_rows[row][15] == '':
self.table_rows[row][15] = 'BRA'
self.table_rows[row][15] = self.config.country if self.config.country else 'BRA'

if self.table_rows[row][7] == 1:
if self.table_rows[row][11] == '':
Expand Down Expand Up @@ -553,3 +553,35 @@ def search_stack(self, function):
>>> is_present = self.search_stack("MATA020")
"""
return len(list(filter(lambda x: x.function == function, inspect.stack()))) > 0

def get_program_name(self):
"""
[Internal]
"""
stack_item_splited = next(iter(map(lambda x: x.filename.split(self.replace_slash("\\")), filter(
lambda x: "TESTSUITE.PY" in x.filename.upper() or "TESTCASE.PY" in x.filename.upper(), inspect.stack()))),
None)

if stack_item_splited:
get_file_name = next(iter(list(
map(lambda x: "TESTSUITE.PY" if "TESTSUITE.PY" in x.upper() else "TESTCASE.PY", stack_item_splited))))

if get_file_name:
program_name = next(iter(list(map(lambda x: re.findall(fr"(\w+)(?:{get_file_name})", x.upper()),
filter(lambda x: ".PY" in x.upper(), stack_item_splited)))), None)

if program_name:
return next(iter(program_name))
else:
return None
else:
return None

def replace_slash(self, path):

slash = r"/" if (sys.platform.lower() == "linux") else r"\\"

pattern = re.compile(r'[\/\\]')

if pattern.findall(path):
return pattern.sub(slash, path)
1 change: 0 additions & 1 deletion tir/technologies/core/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,3 @@ def create_file(folder, filename):
except Exception as error:
time.sleep(30)
logger().debug(str(error))

Loading

0 comments on commit 7887b70

Please sign in to comment.