1

My problem is: I have a running lighttpd web server. The files are stored in \var\www, also a python script, which can be executed to get an image from the raspi camera. Every time the script is called, one image should be delivered to the browser.

The lighttpd itself seems to work, I can see my web page from the browser, I also can execute the phyton script (snap.py). But I get only ONE image from the server. The web server executes the script, the script creates a temporary /run/shm/img.jpg. this image is then delivered by the web server. The web server runs on a user "www-data". I can see that the image in /run/shm is owned by "root" and not by "www-data". And this seems to be the problem.

Once this image is created, all later calls of the script cannot delete the temp. image to create a new one.

I currently have no idea why a web server running with "www-data" access rights creates files bolonging to "root", which later cannot be deleted any more..

I'm using this script on 2 older raspis (older installations). There this script runs fine , but now on a new installation I have this problem...

Can anyone help ?

This is the python script:

#!/usr/bin/python
import sys
import subprocess
import os
import ftplib
import time
import smtplib
import Image
import cStringIO
import SunRiseSet_Lendersdorf

#verschiedene Kameraeinstellungen fuer tag und nacht
FTEMP_DCAM = "/run/shm/img.jpg"
CAPT_UTIL   = "raspistill"  
CAPT_DCAM_DAY   = " -t 500 --ISO 200 -w 1600 -h 1200 -ex auto -o " + FTEMP_DCAM
CAPT_DCAM_NIGHT = " -t 500 --ISO 800 -w 1600 -h 1200 -ex night -o " + FTEMP_DCAM

try:
    os.remove(FTEMP_DCAM)
except OSError:
    pass

# Aktuelle Zeit, Sonnenauf-und Untergangszeit bestimmen
lt = time.localtime()
ActHour  = float(time.strftime("%H" , lt))
ActMin   = float(time.strftime("%M" , lt))
ActHour  = ActHour + ActMin/60.
RiseHour = SunRiseSet_Lendersdorf.GetLendersdorfSunRiseOrSet ( 1 )
SetHour  = SunRiseSet_Lendersdorf.GetLendersdorfSunRiseOrSet ( 0 )

# Zugriff mitloggen
#f = open('SNAP_ACCESS.TXT', 'a')
#f.write(time.strftime("%d.%m.%y %H:%M:%s",lt))
#f.write('\r\n')
#f.close()


try:
    if ActHour > RiseHour and ActHour < SetHour:
        error = subprocess.check_output(CAPT_UTIL+CAPT_DCAM_DAY, shell=True, stderr=subprocess.STDOUT)
        #print "DayTime"
    else:  
        error = subprocess.check_output(CAPT_UTIL+CAPT_DCAM_NIGHT, shell=True, stderr=subprocess.STDOUT)
        #print "NightTime"
except subprocess.CalledProcessError as e:
    #print "CalledProcessError" 
    pass

sys.stdout.write( "Content-Type: image/jpeg;\n\n" + file(FTEMP_DCAM,"rb").read() )
Wolli
  • 11
  • 2

0 Answers0