Page 1 of 1

Script Error Trapping?

Posted: 01 Mar 2019, 17:46
by rvyoung
I've been running a script to control my allsky camera without trouble for many months. I recently started running a Python script that FTP's the saved images to a web site. Now, some random time during the night, I'll get a script error that halts the script. I suspect that Windows is involved. I tried running AstroArt as Administrator but that didn't help. Here's the partial code and output:

Code: Select all

ImgName$ = "sky"+ImgNum$+".jpg"                ' sequenced filename
FilePath$ = AllpicsPath$+ImgName$              ' filename and path
print FilePath$
Image.SaveView(FilePath$)
pause(1)
FilePath$ = AllpicsPath$+"sky"+".jpg"          ' static filename for FTP
print FilePath$
Image.SaveView(FilePath$)

835,2019 02 27,03 07 41,133.09,30,2917,2147
sky0835.fit
C:\Allsky\AllskyPics\sky0835.jpg
C:\Allsky\AllskyPics\sky.jpg
836,2019 02 27,03 08 16,132.97,30,2945,2166
sky0836.fit
C:\Allsky\AllskyPics\sky0836.jpg
C:\Allsky\AllskyPics\sky.jpg
837,2019 02 27,03 08 52,132.86,30,2928,2179
sky0837.fit
C:\Allsky\AllskyPics\sky0837.jpg
C:\Allsky\AllskyPics\sky.jpg
Cannot save image. Check path and filename - Line 269
I'm wondering if there is a way to trap the error and take an alternative action? Likely, delay a second or two then retry. I'm running AstroArt 6 right now (have 7 but haven't loaded yet) and running in Windows 10.

Thanks, Rick

Re: Script Error Trapping?

Posted: 01 Mar 2019, 23:42
by fabdev
Hello, the problem is that you are overwriting the file "sky.jpg"
Sometimes it's possible that it's overwritten while the Python script is reading or transmitting it, maybe with exclusive access.

You could modify the Python script in several ways: it could copy the "sky.jpg" to another file and then transmit the other file.

Or maybe you could not use the "sky.jpg" and let the Python script to open the latest file (837, etc.)

Re: Script Error Trapping?

Posted: 02 Mar 2019, 04:21
by rvyoung
Thanks Fabio.

I'll look at modifying the Python script to be able to avoid using a static filename, so no overwriting occurs.

Rick