0

Apache2 と WSGI を使用して単純な Django Web サイトをホストしています。Web サイトは正常に動作しますが、PiCamera() オブジェクトをインスタンス化しようとすると、このエラーが発生します。私がやろうとしているのは、写真のキャプチャを開始し、Web サイトが更新されるたびに Web サイトの画像を更新することだけです。そんなに難しくないといいなと思います。

私はすべてを検索しましたが、解決策が見つかりません。WSGIApplicationGroup %{GLOBAL} を sites-available/000-default.conf と apache2.conf に追加しようとしました。また、ヘッド バッファ サイズを大きくしようとしましたが、どちらのソリューションも機能しません。どんな助けでも大歓迎です。

Views.py

from django.shortcuts import render
from django.http import HttpResponse
from .models import RelayList
from .forms import RelayControl
from .gpio import Update_Relays
from django.contrib.auth.decorators import login_required
from picamera import PiCamera
from time import sleep


def Snapshot():
    camera = PiCamera() #<---THIS IS WHAT CAUSES THE TRUNCATED ERROR
#   camera.start_preview()
#   sleep(5)
#   camera.capture('/home/calabi/relay_site/power_relay/media/snapshot.jpg')
#   camera.stop_preview()


# Create your views here.
@login_required
def index(response):
    curList = RelayList.objects.get(id=1) #retrieves the database object and places it into a variable
    Snapshot() #takes a photo and saves it to images directory
#   camera = PiCamera()
#   camera.start_preview()
#   sleep(5)
#   camera.capture('/home/calabi/relay_site/power_relay/media/snapshot.jpg')
#   camera.stop_preview()


    if response.method == "POST":
        form = RelayControl(response.POST, instance=curList)

        if form.is_valid():
            form.save()
            Update_Relays(curList.relay1, curList.relay2, curList.relay3)
    else:
        form = RelayControl(instance=curList) # creates an instance of the for defined in class RelayControl in forms.py

    #return HttpResponse('<h1>Hello World, from index in views.py</h1>')
    #"pageHeader" is the variable it looks for in the html file and places whatever is after the ":" in its spot
    return render(response, "power_relay/home.html", {"pageHeader":"Power Relay Controls", "controlForm":form, "curList":curList})



#@login_required
#def modify_model(response):



@login_required
def settings(response):
    return render(response, "power_relay/settings.html", {"pageHeader":"Power Relay Settings"})

000-Default.conf

<VirtualHost *:80>
    #for django
    LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

    Alias /static/admin/ /usr/local/lib/python3.9/dist-packages/django/contrib/admin/static/admin/
    <Directory /usr/local/lib/python3.9/dist-packages/django/contrib/admin/static/admin/>
                Require all granted
        </Directory>

    Alias /static_relay_site/ /home/calabi/relay_site/static/
    <Directory /home/calabi/relay_site/static>
        Require all granted
    </Directory>

    <Directory /home/calabi/relay_site>
        Require all granted
    </Directory>

    <Directory /home/calabi/relay_site/relay_site>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess testing python-path=/home/calabi/relay_site
    WSGIApplicationGroup %{GLOBAL}
    WSGIProcessGroup testing
    WSGIScriptAlias / /home/calabi/relay_site/relay_site/wsgi.py process-group=testing


    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    #DocumentRoot /var/www/html
    #DocumentRoot /home/calabi/relay_site

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

他に投稿すべきファイルがあれば教えてください。

4

0 に答える 0