Guten Abend,
heute bei dem schlechten Wetter dacht ich mir mal mich ganz entspannt hinter meinen Pi zu setzten und ein paar offene Projekte zu bearbeiten..
Nur sitz ich jetzt seit knapp 2h an diesem einen blöden Fehler..-.-
______________________________________________________________________________________________________________________________________________________________
Was habe ich vor?
Ich möchte, dass auf Knopfdruck ein Foto von meiner Tafel geschossen wird. Diese Foto soll dann auf der NAS abgelegt und per Mail an mich gesendet werden.
______________________________________________________________________________________________________________________________________________________________
Was habe ich bis jetzt geschafft?
Ich habe den Pi mit der NAS verbunden.
Ein Script zum Foto aufnehmen und dieses dann auf der NAS ablegen.
(Nur leider ohne Zeitstempel im Namen)
______________________________________________________________________________________________________________________________________________________________
Wie bin ich aufgestellt?
- Raspberry Pi Modell B 512
- SDHC-Karte 16GB mit Raspbian drauf
- Raspberry Kamera Modul
- LAN über Ethernet
- NAS - Buffalo Link Station
______________________________________________________________________________________________________________________________________________________________
Diese Anleitung hat mich begleitet:
Bild%20anfordern%20und%20versenden%20mit%20Email%20via%20CCU.io%20und%20Raspi%20Camera.pdf
______________________________________________________________________________________________________________________________________________________________
Meine Fragen:
- Wieso klappt das mit dem Script nicht ?
- Wie kann ich an den Namen des Fotos das aktuelle Datum ggf. Uhrzeit anhängen?
- Kann ich auch eine Email-Adresse von Strato etc. nehmen oder bin ich an Gmail gebunden? (Frage bezieht sich nur auf die Empfängerseite)
______________________________________________________________________________________________________________________________________________________________
Meine Scripte:
Zum Foto schießen
#!/bin/bash
raspistill -w 1000 -h 1000 -o /home/pi/NAS/myShare/Raspberry_Fotos/image.jpg
#max -w = 2592 Pixel
#max -h = 1944 Pixel
Zum Email senden
#!/usr/bin/python
# Import smtplib for the actual sending function
import smtplib
# Import subprocess to call a shell script
# To call ./cam_pic.sh
import subprocess
# For guessing MIME type
import mimetypes
# Import the email modules we'll need
import email
import email.mime.application
#Import sys to deal with command line arguments
import sys
# First we take the picture from Raspberry Pi camera of shell script
subprocess.call(['/home/pi/Email./cam_pic.sh'])
# Create a text/plain message
msg = email.mime.Multipart.MIMEMultipart()
msg['Subject'] = 'Foto_vom_Raspberry'
msg['From'] = 'raspberryMAIL@gmail.com'
msg['To'] = 'EMPFÄNGER@ADRESSE'
# The main body is just another attachment
body = email.mime.Text.MIMEText("""Der Raspberry schickt ein Foto! """)
msg.attach(body)
# Attachment block code
fp=open('/home/pi/NAS/myShare/Raspberry_Fotos/image.jpg','rb')
att = email.mime.application.MIMEApplication(fp.read(),_subtype='jpg')
fp.close()
att.add_header('Content-Disposition','attachment',filename='image.jpg')
msg.attach(att)
# send via Gmail server
# NOTE: my ISP, Centurylink, seems to be automatically rewriting
# port 25 packets to be port 587 and it is trashing port 587 packets.
# So, I use the default port 25, but I authenticate.
s = smtplib.SMTP('smtp.gmail.com:587')
s.starttls()
s.login('raspberryMAIL@gmail.com','PASSWORT')
s.sendmail('EMPFÄNGER@ADRESSE',['EMPFÄNGER@ADRESSE'], msg.as_string())
s.quit()
Alles anzeigen
Beim Ausführen des Mail-Scripts kommt folgender Fehler:
pi@raspberrypi ~/Email $ python email.py
Traceback (most recent call last):
File "email.py", line 4, in <module>
import smtplib
File "/usr/lib/python2.7/smtplib.py", line 46, in <module>
import email.utils
File "/home/pi/Email/email.py", line 15, in <module>
import email.mime.application
ImportError: No module named mime.application
Wenn ich Spaßeshalber -import mime.application- ausklammer kommt folgender Fehler:
pi@raspberrypi ~/Email $ python email.py
Traceback (most recent call last):
File "email.py", line 4, in <module>
import smtplib
File "/usr/lib/python2.7/smtplib.py", line 46, in <module>
import email.utils
File "/home/pi/Email/email.py", line 22, in <module>
subprocess.call(['/home/pi/Email./cam_pic.sh'])
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Alles anzeigen
Den Dank gibts fürs durchlesen im voraus