bcpkgfox 0.17.5__tar.gz → 0.17.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of bcpkgfox might be problematic. Click here for more details.

@@ -1,10 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: bcpkgfox
3
- Version: 0.17.5
3
+ Version: 0.17.6
4
4
  Summary: Biblioteca BCFOX
5
5
  Home-page: https://github.com/robotsbcfox/PacotePythonBCFOX
6
- Author: Guilherme Neri
7
- Author-email: guilherme.neri@bcfox.com.br
6
+ Author: BCFOX
7
+ Author-email: bcfox@bcfox.com.br
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
@@ -42,3 +42,12 @@ Requires-Dist: pymupdf; extra == "full"
42
42
  Requires-Dist: Pillow; extra == "full"
43
43
  Requires-Dist: psutil; extra == "full"
44
44
  Requires-Dist: pynput; extra == "full"
45
+ Dynamic: author
46
+ Dynamic: author-email
47
+ Dynamic: classifier
48
+ Dynamic: description-content-type
49
+ Dynamic: home-page
50
+ Dynamic: provides-extra
51
+ Dynamic: requires-dist
52
+ Dynamic: requires-python
53
+ Dynamic: summary
@@ -167,7 +167,7 @@ def invoke_api_proc_log(link, id_robo, token):
167
167
  "POST", link, json=payload, headers=headers)
168
168
  print(f"\n{responseinsert.json()}")
169
169
 
170
- def login_2fac(driver, certificate, system, token, code_timeout=10):
170
+ def login_2fac(driver, certificate, system, token, code_timeout=60):
171
171
  import requests
172
172
  import pyautogui
173
173
  from . import mostrar_mensagem
@@ -332,13 +332,9 @@ def login_2fac(driver, certificate, system, token, code_timeout=10):
332
332
  self.driver.get('chrome-extension://lnidijeaekolpfeckelhkomndglcglhh/index.html')
333
333
 
334
334
  def codes_2_fac(self):
335
- element_sistema = '//input[(contains(@placeholder,"selecione um sistema pra acessar") or contains(@name, "system")) and contains(@role, "combobox")]'
336
- element_email = '//input[contains(@placeholder,"Insira aqui o seu email") or contains(@placeholder,"e-mail")]'
337
- email = 'eliezer@bcfox.com.br'
338
- element_code = '//input[contains(@placeholder,"Digite aqui o código que enviamos para o seu e-mail") or contains(@placeholder,"código") or contains(@type,"password")]'
339
- element_submit ='//button[contains(@type, "submit")]'
335
+
340
336
  try:
341
- tools.find_element_with_wait(By.XPATH, f'{element_sistema}', timeout=2).send_keys(self.system)
337
+ tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Digite ou selecione um sistema pra acessar"]', timeout=2).send_keys(self.system)
342
338
  code_insertion = True
343
339
 
344
340
  except:
@@ -346,9 +342,9 @@ def login_2fac(driver, certificate, system, token, code_timeout=10):
346
342
 
347
343
  # Request the code
348
344
  for _ in range(50): # Wait the extension to load
349
- time.sleep(1)
345
+
350
346
  try:
351
- tools.find_element_with_wait(By.XPATH, f'{element_email}', timeout=1).send_keys(f'{email}')
347
+ tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Insira aqui o seu email"]', timeout=1).send_keys('eliezer@bcfox.com.br')
352
348
  time.sleep(1)
353
349
  break
354
350
  except:
@@ -357,145 +353,138 @@ def login_2fac(driver, certificate, system, token, code_timeout=10):
357
353
  # Envia o código pro email, o for é só para tratativa de bugs
358
354
  for _ in range(10):
359
355
  try:
360
- tools.find_element_with_wait(By.XPATH, f'{element_code}', timeout=1)
356
+ tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Digite aqui o código que enviamos para o seu e-mail"]', timeout=1)
361
357
  break
362
358
 
363
359
  except:
364
360
  try:
365
- element = tools.find_element_with_wait(By.XPATH, f'{element_email}', timeout=1)
361
+ element = tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Insira aqui o seu email"]', timeout=1)
366
362
  element.clear()
367
- element.send_keys(f'{email}')
368
- tools.find_element_with_wait(By.XPATH, f'{element_submit}').click()
363
+ element.send_keys('eliezer@bcfox.com.br')
364
+ tools.find_element_with_wait(By.XPATH, '//button').click()
369
365
  time.sleep(1)
370
366
  except:
371
367
  break
372
368
 
373
369
  # Attempts the new codes until success or requests limit
374
370
  for _ in range(code_timeout):
375
- def adicionar_code():
376
- responses = api.invoke_get_codes()
377
- if not responses:
378
- time.sleep(2)
379
- return [], None
380
- # Try new codes
381
- code_insertion = False
382
- for response in responses:
383
- time.sleep(1)
371
+ responses = api.invoke_get_codes()
384
372
 
385
- if 'Escolha um certificado' in self.driver.page_source:
386
- break
387
-
388
- CODE = response['CODIGO']
389
- ID = response['ID']
373
+ # Try new codes
374
+ code_insertion = False
375
+ for response in responses:
390
376
 
391
- element = tools.find_element_with_wait(By.XPATH, '//input[@type="password"]')
392
- element.clear()
393
- element.send_keys(CODE)
394
- button_entrar_click = False
395
- for _ in range(20):
396
- try:
397
- button = tools.find_element_with_wait(By.XPATH, f'{element_submit}', timeout=2)
398
- if button.get_attribute('disabled'):
399
- time.sleep(1.5)
400
- continue
401
- button.click()
402
- button_entrar_click = True
403
- if 'Escolha um certificado' in self.driver.page_source:
404
- break
405
-
406
- time.sleep(1)
407
- except:
408
- break
409
-
410
- if int(_) == 20 and button_entrar_click == False:
411
- raise TimeoutError('Código Whom falhou ao entrar')
412
-
413
- return responses, ID
414
-
415
- responses, ID = adicionar_code()
416
-
417
- if 'Sair' in self.driver.page_source and not 'Verifique seu e-mail' in self.driver.page_source:
418
- api.invoke_update_status(ID) # FIX: Update
419
- break
377
+ CODE = response['CODIGO']
378
+ ID = response['ID']
420
379
 
421
- if 'Verifique seu e-mail':
422
- responses,ID = adicionar_code()
380
+ element = tools.find_element_with_wait(By.XPATH, '//input[@type="password"]')
381
+ element.clear()
382
+ element.send_keys(CODE)
423
383
 
424
- for _ in range(60):
425
- if not(responses):
426
- responses,ID = adicionar_code()
427
- time.sleep(1)
428
- else:
429
- break
384
+ for _ in range(10):
385
+ try:
386
+ tools.find_element_with_wait(By.XPATH, '//div/div[2]/button', timeout=2).click()
387
+ time.sleep(1)
388
+ except:
389
+ break
430
390
 
431
- if not (responses):
432
- raise TimeoutError('Código WHOOM não chegou dentro do timeout estabelecido')
433
- # Wrong
391
+ # Check the code result
392
+ for _ in range(30):
434
393
 
435
- try:
436
- tools.find_element_with_wait(By.XPATH, "//span[contains(text(), 'Senha inválida')]",
437
- timeout=1)
438
- tools.find_element_with_wait(By.XPATH, "//button[text()='Voltar']", timeout=1).click()
439
- code_insertion = False
440
- break
394
+ # Correct
395
+ try:
396
+ # input('\n\n > Selecione o sistema e aperte alguma tecla.')
397
+ tools.find_element_with_wait(By.XPATH, '//input[@placeholder="Digite ou selecione um sistema pra acessar"]', timeout=1).send_keys(self.system)
398
+ api.invoke_update_status(ID) #FIX: Update
399
+ code_insertion = True
400
+ break
441
401
 
442
- except:
443
- pass
402
+ except:
403
+ pass
444
404
 
445
- if 'Sair' in self.driver.page_source and not 'Verifique seu e-mail' in self.driver.page_source:
446
- api.invoke_update_status(ID) # FIX: Update
447
- break
405
+ # Wrong
406
+ try:
407
+ tools.find_element_with_wait(By.XPATH, "//span[contains(text(), 'Senha inválida')]", timeout=1)
408
+ tools.find_element_with_wait(By.XPATH, "//button[text()='Voltar']", timeout=1).click()
409
+ code_insertion = False
410
+ break
448
411
 
449
- code_insertion = False
450
- # Check the code result
451
- for _ in range(30):
452
- if code_insertion:
453
- break
454
- # Correct
455
- try:
456
- tools.find_element_with_wait(By.XPATH,"//input[(contains(@name,'certificate') or contains(@placeholder,'certificado')) and not(contains(@type, 'hidden'))]", timeout=1).send_keys(self.certificate)
457
- list_certific = tools.find_elements_with_wait(By.XPATH,'//div[contains(@role,"option")]')
458
- list_certific[0].click()
459
- time.sleep(1)
460
- code_insertion = True
461
- break
462
- except:
463
- pass
412
+ except:
413
+ pass
464
414
 
465
- time.sleep(4)
466
- code_insertion = False
467
- for _ in range(30):
468
- try:
469
- # input('\n\n > Selecione o sistema e aperte alguma tecla.')
470
- tools.find_element_with_wait(By.XPATH, f'{element_sistema}', timeout=1).send_keys(self.system)
415
+ # If the 'new_response' loop succeeds immediately
416
+ if not responses:
471
417
  time.sleep(1)
472
- list_sistemas = tools.find_elements_with_wait(By.XPATH, '//div[contains(@role,"option")]')
473
- if len(list_sistemas) == 1:
474
- list_sistemas[0].click()
475
- code_insertion = True
476
- break
477
- else:
478
- mostrar_mensagem(
479
- 'Mais de um sistema encontrado, verifique o nome do sistema no WHOOM e coloque um nome único na função')
480
- raise ValueError('Mais de um sistema encontrado, verifique o nome')
481
- except:
482
- pass
483
418
 
484
419
  if code_insertion:
485
420
  break
486
421
 
487
- if code_insertion:
488
- tools.find_element_with_wait(By.XPATH, f"//button[contains(@data-testid,'submit') or contains(text(), 'Acessar')]").click()
489
- print('Logado')
490
- else:
422
+ if not(code_insertion):
491
423
  raise TimeoutError('Código WHOOM não chegou dentro do timeout estabelecido')
492
424
 
493
- time.sleep(2)
425
+ time.sleep(4)
426
+ # Selects the system to access
427
+ lines = tools.find_elements_with_wait(By.XPATH, '//div[@role="menu"]//div[@role="menuitem"]')
428
+
429
+ finded = False
430
+ div_list = []
431
+
432
+ # This loop extract the lines with the system name
433
+ for line in lines:
434
+
435
+ titulo_element = line.find_elements(By.XPATH, './span[*[name()="svg"]]')
436
+
437
+ if not titulo_element and not finded:
438
+ continue
439
+
440
+ elif titulo_element and not finded:
441
+ titulo_text = line.find_element(By.XPATH, './span').text
442
+ if self.certificate.lower().strip() in titulo_text.lower().strip():
443
+ finded = True
444
+ continue
445
+
446
+ elif not titulo_element and finded:
447
+ div_list.append(line)
448
+
449
+ elif titulo_element and finded:
450
+ break
451
+
452
+ if not div_list:
453
+ mostrar_mensagem('Não conseguiu achar o sistema no certificado')
454
+ raise ValueError('Não conseguiu achar o sistema no certificado')
455
+
456
+ if len(div_list) == 1:
457
+ time.sleep(1)
458
+ div_list[0].click()
459
+
460
+ # Just do this loop if there are more than one system
461
+ else:
462
+ for div in div_list:
463
+ div_text = div.find_element(By.XPATH, './span').text
464
+ if self.system.lower().strip() not in div_text.lower().strip():
465
+ div_list.remove(div)
466
+
467
+ if len(div_list) == 1:
468
+ div_list[0].click()
469
+ else:
470
+ mostrar_mensagem('Mais de um sistema encontrado, verifique o nome do sistema no WHOOM e coloque um nome único na função')
471
+ raise ValueError('Mais de um sistema encontrado, verifique o nome')
472
+
473
+ # Verifies if the system was opened
474
+ for _ in range(30):
475
+ time.sleep(1)
476
+ if len(self.driver.window_handles) == 1:
477
+ try:
478
+ tools.find_element_with_wait(By.XPATH, "//button[text()='Acessar']", timeout=1).click()
479
+ except:
480
+ time.sleep(1)
481
+ else:
482
+ time.sleep(3)
483
+ break
484
+
494
485
  self.driver.switch_to.window(self.driver.window_handles[-1])
495
486
  attempt = 0
496
487
  while 'whoom' in self.driver.title.strip().lower() and attempt <= 180:
497
- if 'Sistema temporariamente indisponível. Tente novamente mais tarde.' in self.driver.page_source:
498
- raise SystemError('Sistema indisponivel no momento.')
499
488
  time.sleep(1)
500
489
  attempt += 1
501
490
  time.sleep(5)
@@ -1,10 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: bcpkgfox
3
- Version: 0.17.5
3
+ Version: 0.17.6
4
4
  Summary: Biblioteca BCFOX
5
5
  Home-page: https://github.com/robotsbcfox/PacotePythonBCFOX
6
- Author: Guilherme Neri
7
- Author-email: guilherme.neri@bcfox.com.br
6
+ Author: BCFOX
7
+ Author-email: bcfox@bcfox.com.br
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
@@ -42,3 +42,12 @@ Requires-Dist: pymupdf; extra == "full"
42
42
  Requires-Dist: Pillow; extra == "full"
43
43
  Requires-Dist: psutil; extra == "full"
44
44
  Requires-Dist: pynput; extra == "full"
45
+ Dynamic: author
46
+ Dynamic: author-email
47
+ Dynamic: classifier
48
+ Dynamic: description-content-type
49
+ Dynamic: home-page
50
+ Dynamic: provides-extra
51
+ Dynamic: requires-dist
52
+ Dynamic: requires-python
53
+ Dynamic: summary
@@ -2,9 +2,9 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="bcpkgfox",
5
- version="0.17.5",
6
- author="Guilherme Neri",
7
- author_email="guilherme.neri@bcfox.com.br",
5
+ version="0.17.6",
6
+ author="BCFOX",
7
+ author_email="bcfox@bcfox.com.br",
8
8
  description="Biblioteca BCFOX",
9
9
  long_description=open("README.md").read(),
10
10
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes
File without changes
File without changes