Python script called by OpenHAB rule fails to write jpg file

The below script when executed by a OpenHAB rule fails.
When executed in console the script works perfect.

Please assist in troubleshooting.

import commands
import datetime
import time
import urllib2
import os
import smtplib

file = “doorbell.jpg”

try:
jpgfile = urllib2.urlopen(“http://192.168.1.9:9989/?action=snapshot”)
output = open(‘doorbell.jpg’,‘wb’)
output.write(jpgfile.read())
output.close()

except IOError:
print(‘An error occured trying to read the file.’)

Permission Problem ?

In Openhab is the User openhab!
Shell on Raspberry is the User Pi or for Openhabiian is the User Openhabian

This has helped me a lot. Permissions issue was correct.
Thanks

1 Like