ImpulsoGov/etl

(impulsoetl) Problema de permissão em capturas do SISAB com Selenium

bcbernardo opened this issue · 0 comments

As capturas de relatórios do SISAB que ainda utilizam Selenium estão retornando um erro, aparentemente relacionado à permissão de acesso ao executável do navegador automatizado.

Logs do Github Action:

2022-07-19 06:05:30.453 | INFO     | impulso***.scripts.saude_mental:resolutividade_aps_por_condicao:44 - Capturando dados de resolutividade da APS (desfechos de atendimentos individuais) por condição de saúde avaliada.
2022-07-19 06:05:30.716 | INFO     | impulso***.sisab.producao:obter_relatorio_producao:1349 - Iniciando captura de relatório de produção com as variáveis ['Conduta', 'Problema/Condição Avaliada'] para 1 municípios na competencia de 5/2022.
2022-07-19 06:05:31.752 | ERROR    | impulso***.scripts.saude_mental:***:304 - An error has been caught in function '***', process 'MainProcess' (1), thread 'MainThread' (140712654780224):
Traceback (most recent call last):
  File "/home/appuser/.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
    │              │          │     │        │    └ environ({'PATH': '/home/appuser/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOS...
    │              │          │     │        └ <selenium.webdriver.firefox.service.Service object at 0x7ffa14303430>
    │              │          │     └ ['', '--websocket-port', '38983', '--port', '55761']
    │              │          └ <class 'subprocess.Popen'>
    │              └ <module 'subprocess' from '/usr/local/lib/python3.8/subprocess.py'>
    └ <selenium.webdriver.firefox.service.Service object at 0x7ffa14303430>
  File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
    │    │              │     │           │           └ True
    │    │              │     │           └ None
    │    │              │     └ None
    │    │              └ ['', '--websocket-port', '38983', '--port', '55761']
    │    └ <function Popen._execute_child at 0x7ffa313c1280>
    └ <subprocess.Popen object at 0x7ffa1424d880>
  File "/usr/local/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
          │                    │          │        └ ''
          │                    │          └ 'Permission denied'
          │                    └ 13
          └ <class 'OSError'>
PermissionError: [Errno 13] Permission denied: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "src/impulso***/__main__.py", line 14, in <module>
    ***()
    └ <function *** at 0x7ffa379e7c10>
  File "/home/appuser/.local/lib/python3.8/site-packages/impulso***/***.py", line 18, in ***
    capturas_saude_mental(sessao=sessao, teste=teste)
    │                            │             └ False
    │                            └ <sqlalchemy.orm.session.Session object at 0x7ffa37a6a9a0>
    └ <function *** at 0x7ffa14302b80>
> File "/home/appuser/.local/lib/python3.8/site-packages/impulso***/scripts/saude_mental.py", line 304, in ***
    resolutividade_aps_por_condicao(sessao=sessao, teste=teste)
    │                                      │             └ False
    │                                      └ <sqlalchemy.orm.session.Session object at 0x7ffa37a6a9a0>
    └ <function resolutividade_aps_por_condicao at 0x7ffa14301670>
  File "/home/appuser/.local/lib/python3.8/site-packages/impulso***/scripts/saude_mental.py", line 57, in resolutividade_aps_por_condicao
    obter_relatorio_producao(
    └ <function obter_relatorio_producao at 0x7ffa14301790>
  File "/home/appuser/.local/lib/python3.8/site-packages/impulso***/utilitarios/repetidores.py", line 178, in wrapper
    [
  File "/home/appuser/.local/lib/python3.8/site-packages/impulso***/utilitarios/repetidores.py", line 179, in <listcomp>
    funcao(ano=dt.year, mes=dt.month, *args, **kwargs)
    │          │  │         │  │       │       └ {'tabela_destino': 'dados_publicos.sisab_producao_municipios_por_conduta_por_problema_condicao_ava', 'variaveis': ('Conduta',...
    │          │  │         │  │       └ ()
    │          │  │         │  └ <attribute 'month' of 'datetime.date' objects>
    │          │  │         └ Timestamp('2022-05-01 00:00:00', freq='MS')
    │          │  └ <attribute 'year' of 'datetime.date' objects>
    │          └ Timestamp('2022-05-01 00:00:00', freq='MS')
    └ <function obter_relatorio_producao at 0x7ffa14301700>
  File "/home/appuser/.local/lib/python3.8/site-packages/impulso***/sisab/producao.py", line 1371, in obter_relatorio_producao
    with criar_geckodriver() as driver:
         └ <function criar_geckodriver at 0x7ffa1436a700>
  File "/usr/local/lib/python3.8/contextlib.py", line [113](https://github.com/ImpulsoGov/etl/runs/7403356657?check_suite_focus=true#step:5:114), in __enter__
    return next(self.gen)
                │    └ <generator object criar_geckodriver at 0x7ffa1431d200>
                └ <contextlib._GeneratorContextManager object at 0x7ffa14303640>
  File "/home/appuser/.local/lib/python3.8/site-packages/impulso***/navegadores.py", line 101, in criar_geckodriver
    driver = webdriver.Firefox(service=servico, options=opcoes)
             │         │               │                └ <selenium.webdriver.firefox.options.Options object at 0x7ffa1424d040>
             │         │               └ <selenium.webdriver.firefox.service.Service object at 0x7ffa14303430>
             │         └ <class 'selenium.webdriver.firefox.webdriver.WebDriver'>
             └ <module 'selenium.webdriver' from '/home/appuser/.local/lib/python3.8/site-packages/selenium/webdriver/__init__.py'>
  File "/home/appuser/.local/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    self.service.start()
    │    │       └ <function Service.start at 0x7ffa14466820>
    │    └ <selenium.webdriver.firefox.service.Service object at 0x7ffa[143](https://github.com/ImpulsoGov/etl/runs/7403356657?check_suite_focus=true#step:5:144)03430>
    └ <unprintable WebDriver object>
  File "/home/appuser/.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 86, in start
    raise WebDriverException(
          └ <class 'selenium.common.exceptions.WebDriverException'>
selenium.common.exceptions.WebDriverException: Message: '' executable may have wrong permissions.