samedi 30 juin 2018

Python script execution error in Laravel controller

Currently my scripts work perfectly within the schedule that run at specific times within my server's cron.Currently my scripts work perfectly within the schedule that run at specific times within my server's cron.

The problem is occurring when I try to execute the method inside the controller, this method basically uses a shell_exec() that executes a script in python and this return is what I deal with Laravel.

When I call it from the console or the schedule it works correctly, but when I call the method or even an \Artisan::call('schedule:test'); it returns the same error saying that it is not finding the geckdriver.

The command "python C:/wamp64/www/MoneyGuard/pythonGuard/tesouro_direto/tesouro_direto_precos_taxa_titulo.py" failed.
Exit Code: 1(General error)
Working directory: C:\wamp64\www\MoneyGuard\public
Output:
================
[ {"inicio": "2018-06-30 11:04:23.830834"},
Error Output:
================
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] O sistema não pode encontrar o arquivo especificado
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:/wamp64/www/MoneyGuard/pythonGuard/tesouro_direto/tesouro_direto_precos_taxa_titulo.py", line 17, in <module>
    firefox = webdriver.Firefox(firefox_options=opts)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 152, in __init__
    self.service.start()
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

When I run it inside the terminal: it works perfectly:

λ php artisan schedule:teste
[ {"inicio": "2018-06-29 17:23:08.963534"},
 { "titulo": "Tesouro IPCA+ 2024", "vencimento": "2024-08-15 00:00:00", "taxa_rendimento": "5.62", "valor_minimo": "44.50", "preco_unitario": "2225.41" },
 { "titulo": "Tesouro IPCA+ 2035", "vencimento": "2035-05-15 00:00:00", "taxa_rendimento": "5.87", "valor_minimo": "35.72", "preco_unitario": "1190.74" },
 { "titulo": "Tesouro IPCA+ 2045", "vencimento": "2045-05-15 00:00:00", "taxa_rendimento": "5.87", "valor_minimo": "33.70", "preco_unitario": "674.18" },
 { "titulo": "Tesouro IPCA+ com Juros Semestrais 2026", "vencimento": "2026-08-15 00:00:00", "taxa_rendimento": "5.68", "valor_minimo": "32.40", "preco_unitario": "3240.59" },
 { "titulo": "Tesouro IPCA+ com Juros Semestrais 2035", "vencimento": "2035-05-15 00:00:00", "taxa_rendimento": "5.79", "valor_minimo": "32.04", "preco_unitario": "3204.72" },
 { "titulo": "Tesouro IPCA+ com Juros Semestrais 2050", "vencimento": "2050-08-15 00:00:00", "taxa_rendimento": "5.88", "valor_minimo": "32.36", "preco_unitario": "3236.30" },
 { "titulo": "Tesouro Prefixado 2021", "vencimento": "2021-01-01 00:00:00", "taxa_rendimento": "9.20", "valor_minimo": "32.09", "preco_unitario": "802.49" },
 { "titulo": "Tesouro Prefixado 2025", "vencimento": "2025-01-01 00:00:00", "taxa_rendimento": "11.44", "valor_minimo": "34.66", "preco_unitario": "495.21" },
 { "titulo": "Tesouro Selic 2023", "vencimento": "2023-03-01 00:00:00", "taxa_rendimento": "0.02", "valor_minimo": "95.72", "preco_unitario": "9572.17" },
{"fim": "2018-06-29 17:23:19.484442"} ]

Python Script: tesouro_direto_precos_taxa_titulo.py

From what I'm noticing when I run the command inside the controller, it is not using the path of my system. the question is why?

I thank you in advance for any help.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2KsOFrJ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire