how to trouble shoot - RuntimeError: Open Failed

S

stas poritskiy

hey guys,
I am working on application. App is processing a list of files in folders.
Folders act as a NEW-LOOP. so if all files in one folder had been worked on, file is then saved and next folder is picked up.
it works fine only if i have a SINGLE folder, however, when another folder is there, i get this RuntimeError: Open Failed.
I checked if those could be the files by leaving only single (another folder), however all was fine.
Questions - How can i trouble shoot what is causing the problem? i don't know where to begin.

Thanks!
 
S

Steven D'Aprano

hey guys,
I am working on application. App is processing a list of files in
folders. Folders act as a NEW-LOOP. so if all files in one folder had
been worked on, file is then saved and next folder is picked up. it
works fine only if i have a SINGLE folder, however, when another folder
is there, i get this RuntimeError: Open Failed. I checked if those could
be the files by leaving only single (another folder), however all was
fine. Questions - How can i trouble shoot what is causing the problem? i
don't know where to begin.

You should ALWAYS begin with the entire traceback, not just the last
line. Everything starting with:

Traceback (most recent call last):


and ending with the last line, which in your case will be something like
"RuntimeError: Open failed". The most important part is that the
traceback will actually show you the line that fails.

Secondly, whose code is this? I assume it is code you have written. In
that case, do you have something like this in your code?

try:
blah blah blah # whatever, doesn't matter what this is
except:
raise RuntimeError("Open failed")


If so, take it out immediately! All you are doing is catching a *useful*
exception that Python generates, and replacing it with an utterly useless
exception that does nothing but hide the true cause of the problem and
make debugging much more difficult.


That will do to start. If you still need help, please copy and paste the
entire traceback. Also, demonstrating a *minimal* amount of code that
causes this error will help. Although this is written for Java
programmers, the same principles apply to Python code too:

http://sscce.org/
 
N

Neil Cerutti

I am working on application. App is processing a list of files
in folders. Folders act as a NEW-LOOP. so if all files in one
folder had been worked on, file is then saved and next folder
is picked up. it works fine only if i have a SINGLE folder,
however, when another folder is there, i get this RuntimeError:
Open Failed. I checked if those could be the files by leaving
only single (another folder), however all was fine. Questions -
How can i trouble shoot what is causing the problem? i don't
know where to begin.

We can help better if you show some of your code; a minimal
cut-down version that exhibits the error is ideal.

Are you literally getting a RuntimeError? That would be weird.
 
S

stas poritskiy

The code in development is mine, and i am using the API provided by a main developer.

At the moment, i am not using any try/except functionality.

here is the full Exception output:
Code:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\32bit\lib\lib-tk\Tkinter.py", line 1470, in __call__
return self.func(*args)
File "E:\sporitskiy\HON\Project\scene7\s7operator\gui.py", line 59, in <lambda>
cmd1 = lambda: vntProcessor.colData(folders.path, folders.subFolders)
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 184, in colData
setVars()
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 79, in __call__
self.batchFiles()
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 55, in batchFiles
self.vntConnect.createVNTobjects(self.vntObjMgroup.keyList, self.vntLtoF.keyValList, self.vntObjFile.keyList, myPath)
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 113, in createVNTobjects
self.createImage(groupName, layerName, fileName, imagePath, self.vntGroups)
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 137, in createImage
img = open_image(imageFile)
File "<string>", line 2, in open_image
File "C:\Python27\32bit\lib\site-packages\s7vampy\arg_validator.py", line213, in __call__
return func(*args, **keywords)
File "C:\Python27\32bit\lib\site-packages\s7vampy\image.py", line 181, inopen_image
return Image(_S7VAM_IMAGE.Open(filename))
RuntimeError: Open Failed: 'C:/Users/sporitskiy/Desktop/Practice/HIWM2MSB/hiwm2mpa_upholstery_esq_leather_ro_12_0001.tif'

-- Just a few words on what this all does --

Structure: 3 modules
Module 1 - dataPreparation.py -responsible for string processing - made of several classes and methods that receive PATH to directory, collect all files in a LIST, after that for each file based on type of file name it sorts it out to appropriate categories that can be accessed through class instances.

Module 2 - gui.py - Responsible for GUI. It crates a simple GUi-layout thatoffer BROWSE button (to get the PATH), QUIT button to exit application, LISTBOX that lists subfolders from the PATH, and BATCH button that must execute the main processor.

Module 3 - vntProcessor.py - Responsible for processing of collected data. This module is based of an API of another application. It receives the values from the BATCH-button and invokes specific methods based on sorting thatwas performed using MODULE 1.

My approach:

i created an instance of GUI and call it to start interface ( have a windowopen) in the interface, i browse for specific folder, so my PATH variable is set. my list box is populated with subfolders.(using Tkinter for gui)

my next step should be to press the BATCH folder and forward all of the values (PATH and ARRAY of SUBFOLDERS) to my Module 3 (processor).
and as soon as my script tries to open NEXT FOLDER is when i get this RuntimeError, but if i leave the same folder by itself - everything is fine.

If by looking at the Exception Log i posted, you could tell me what portionof the code i should show here - it would be very helpful. thanks!
 
T

Terry Reedy

The code in development is mine, and i am using the API provided by a main developer.

At the moment, i am not using any try/except functionality.

here is the full Exception output:
Code:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\32bit\lib\lib-tk\Tkinter.py", line 1470, in __call__
return self.func(*args)
File "E:\sporitskiy\HON\Project\scene7\s7operator\gui.py", line 59, in <lambda>
cmd1 = lambda: vntProcessor.colData(folders.path, folders.subFolders)
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 184, in colData
setVars()
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 79, in __call__
self.batchFiles()
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 55, in batchFiles
self.vntConnect.createVNTobjects(self.vntObjMgroup.keyList, self.vntLtoF.keyValList, self.vntObjFile.keyList, myPath)
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 113, in createVNTobjects
self.createImage(groupName, layerName, fileName, imagePath, self.vntGroups)
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 137, in createImage
img = open_image(imageFile)
File "<string>", line 2, in open_image
File "C:\Python27\32bit\lib\site-packages\s7vampy\arg_validator.py", line 213, in __call__
return func(*args, **keywords)
File "C:\Python27\32bit\lib\site-packages\s7vampy\image.py", line 181, in open_image
return Image(_S7VAM_IMAGE.Open(filename))
RuntimeError: Open Failed: 'C:/Users/sporitskiy/Desktop/Practice/HIWM2MSB/hiwm2mpa_upholstery_esq_leather_ro_12_0001.tif'[/QUOTE]

We were confused because the failed open should be an IOError. If Image
is indeed converting such to RuntimeError, it should not. It should just
let the original error bubble up. It is possibly tossing information in
the process. The first thing I would do is to look at the code around
that line in image.py and remove the exception replacement if there is one.
 
S

stas poritskiy

Guys, as i was writing a very detailed message with code samples, following the guide that Steven linked, i found the problem. a pretty lame one, actually.

in my class that was processing the images, i created an object instance, via
__INIT__ , self.data = attributes()
but i was iterating through list of folders, so object was filled with the correct data, but it was never re-initialized for the new one.

i move my objects into a function, and called the function on each loop-start,
so objects are re-created and re-filled with the data.


Terry, yeah, your confusion was right, and pointing out that i was supposed to get IOError. that lead me to inspect code again and again :)

anyways, thanks and sorry for the mess )





The code in development is mine, and i am using the API provided by a main developer.
At the moment, i am not using any try/except functionality.
here is the full Exception output:
Code:
[/QUOTE]

Exception in Tkinter callback[/QUOTE]
[QUOTE]
Traceback (most recent call last):[/QUOTE]
[QUOTE]
File "C:\Python27\32bit\lib\lib-tk\Tkinter.py", line 1470, in __call__[/QUOTE]
[QUOTE]
return self.func(*args)[/QUOTE]
[QUOTE]
File "E:\sporitskiy\HON\Project\scene7\s7operator\gui.py", line 59, in <lambda>[/QUOTE]
[QUOTE]
cmd1 = lambda: vntProcessor.colData(folders.path, folders.subFolders)[/QUOTE]
[QUOTE]
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 184, in colData 

File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 79, in __call__ 

File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 55, in batchFiles[/QUOTE]
[QUOTE]
self.vntConnect.createVNTobjects(self.vntObjMgroup.keyList, self.vntLtoF.keyValList, self.vntObjFile.keyList, myPath)[/QUOTE]
[QUOTE]
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 113, in createVNTobjects[/QUOTE]
[QUOTE]
self.createImage(groupName, layerName, fileName, imagePath, self.vntGroups)[/QUOTE]
[QUOTE]
File "E:\sporitskiy\HON\Project\scene7\s7operator\vntProcessor.py", line 137, in createImage[/QUOTE]
[QUOTE]
img = open_image(imageFile)[/QUOTE]
[QUOTE]
File "<string>", line 2, in open_image[/QUOTE]
[QUOTE]
File "C:\Python27\32bit\lib\site-packages\s7vampy\arg_validator.py", line 213, in __call__[/QUOTE]
[QUOTE]
return func(*args, **keywords)[/QUOTE]
[QUOTE]
File "C:\Python27\32bit\lib\site-packages\s7vampy\image.py", line 181, in open_image[/QUOTE]
[QUOTE]
return Image(_S7VAM_IMAGE.Open(filename))[/QUOTE]
[QUOTE]
RuntimeError: Open Failed: 'C:/Users/sporitskiy/Desktop/Practice/HIWM2MSB/hiwm2mpa_upholstery_esq_leather_ro_12_0001.tif'[/QUOTE]



We were confused because the failed open should be an IOError. If Image

is indeed converting such to RuntimeError, it should not. It should just

let the original error bubble up. It is possibly tossing information in

the process. The first thing I would do is to look at the code around

that line in image.py and remove the exception replacement if there is one.
[/QUOTE]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top