To setup this question, I'm using Python in the form of Jython 2.7 (in Ignition SCADA). I have a function that copies image files to a print spool network folder. Occasionally I get an error like the following: An ERROR occured: Line - 241: <type 'exceptions.IOError'>, [Errno 2] No such file or directory: u'\\server23\eFormz\D1234567.tif'. Part - ABC1234X12, while printing label.
These print jobs run through a number of different parts in the same order but only 1 or 2 generate this error. All others copy the file as expected. The error is calling out the DESTINATION file path in all cases. The destination folder exists as all of the good copies are going to the same folder as those that cause errors.
The code that does the copy looks like this:
import shutil
imgFiles = glob.glob(labelImage)
if len(imgFiles) > 0:
imgFile = imgFiles[0]
#ensure the image file path is actually a file
if os.path.isfile(imgFile):
fileName = imgFile.rsplit('\\', 1)[1]
dstFP = '\\\\server23\\eFormz\\' + fileName
shutil.copyfile(imgFile, dstFP)
Since this works most of the time, with the same folder paths and only the file name changing (all the source files are confirmed to exist and confirmed that they are indeed files, before attempting the copy), I'm perplexed as to the cause. File and folder permissions are the same for each so that should not be the cause.
Any ideas as to what may be causing this or a way to more effectively troubleshoot it would be appreciated.
Thanks.