Re: Once again down that hole
Posted: Tue Jun 12, 2018 7:34 pm
So very very close, AND I've greatly simplified the mess.
But (and there's always a but) I have a problem with what I think is effectively simultaneous execution. The first part of my script takes time, because it involves network activities:
But as I think I read somewhere, Python executes everything as fast as it can, rather than in order. So any time I've run this after the first, this part acts on the previous image before the new image is saved:
To be clear, I'm grabbing an image from the camera, and then want to reduce its quality and size. Right now, the action group is reducing the PREVIOUS image, which is then overwritten immediately by the new image. I know this because I'm watching that Finder directory, and when I run this, the old image drops in size by 70 % or so, and then is overwritten.
But now I'm doubly confused because I just read this suggesting Python executes from top to bottom.
But (and there's always a but) I have a problem with what I think is effectively simultaneous execution. The first part of my script takes time, because it involves network activities:
- Code: Select all
from PIL import Image
import subprocess
import time
pic_destination = "/Library/Application Support/Perceptive Automation/Indigo 7/IndigoWebServer/public/whatever.PNG"
subprocess.Popen("wget --user name --password value --no-check-certificate 192.168.999.999/cgi-bin/currentpic.cgi -O /Library/Application\ Support/Perceptive\ Automation/Indigo\ 7/IndigoWebServer/whatever.PNG", shell=True)
But as I think I read somewhere, Python executes everything as fast as it can, rather than in order. So any time I've run this after the first, this part acts on the previous image before the new image is saved:
- Code: Select all
time.sleep(5). <--------even with this ridiculous value
pic = Image.open(pic_destination)
pic.save("/Library/Application Support/Perceptive Automation/Indigo 7/IndigoWebServer/public/whatever.PNG", optimize=True, quality=80, format='PNG')
To be clear, I'm grabbing an image from the camera, and then want to reduce its quality and size. Right now, the action group is reducing the PREVIOUS image, which is then overwritten immediately by the new image. I know this because I'm watching that Finder directory, and when I run this, the old image drops in size by 70 % or so, and then is overwritten.
But now I'm doubly confused because I just read this suggesting Python executes from top to bottom.