Python, - what I should get as a result?

  • Last Post 19 December 2019
Gosforth posted this 18 December 2019

I run using command:


 result ="python "+filePrefix+"/PythonAbbyy/ "+filename+" "+filePrefix+"/out/text/header/"+name+".txt", timeout=6, shell=True)

except subprocess.TimeoutExpired:
 error = "Error"

But result returns NOTHING if process did run successfuly and I'm only display "error" when it failed.

What this process return if success and what if failure? How the correct try: except: should look like?



Order By: Standard | Newest | Votes
Koen de Leijer posted this 19 December 2019


I was waiting for an answer for your previous question


until I saw these two new ones.




It should not be that hard after all with Python, please follow these steps:

Then tell me what output you get after step "5"

Or have a look at another sample from ABBYY



Best regards

Koen de Leijer


Gosforth posted this 19 December 2019

The problem is that output is not any structured data. So when process ended successfully you have:

python "test.png" result.txt
Id = 144bc4da-600f-4b0d-824b-95c6c55faf0a
Status = Queued
Status = Completed
Result was written to result.txt

But when for instance there is no connection you have:

>python "test.png" result.txt
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Continuum\miniconda3\lib\site-packages\urllib3\", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "C:\Users\AppData\Local\Continuum\miniconda3\lib\site-packages\urllib3\util\", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "C:\Users\AppData\Local\Continuum\miniconda3\lib\", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\AppData\Local\Continuum\miniconda3\lib\site-packages\urllib3\", line 600, in urlopen

You have no error handling in

You do NOT return any structured data like JSON or at least XML.

I'm not expert in Python so I ask how to manage it and know if could connect to your service, how to know if completed sucessfully, how to continue next file processing even if timout...(happens often).