Hallo,
sehr interessanter und hilfreicher Beitrag.
Ich muss noch mal das Thema "Starten im Hintergrund" aufwärmen.
Ich möchte die unten aufgeführten Startbefehle verwenden, um den Listener laufen zu lassen und mich wieder vom RPi abzumelden.
Leider kommt eine Fehlermeldung beim Aufrufen, die ich nicht verstehe bzw. lösen kann.
Folgende Befehle habe ich versucht, die immer die gleiche Fehlermeldung gebracht haben.
# Aufruf 1
/var/www/homecontrol/whatsapp/yowsup-cli -c /var/www/homecontrol/whatsapp/config -l -k -a 1> /dev/null 2> /var/www/homecontrol/whatsapp/error.txt &
# Aufruf 2
nohub /var/www/homecontrol/whatsapp/yowsup-cli -c /var/www/homecontrol/whatsapp/config -l -k -a 1> /dev/null 2> /var/www/homecontrol/whatsapp/error.txt &
Die Fehlermeldung lautet.
Zitat
Traceback (most recent call last):
File "/var/www/homecontrol/whatsapp/yowsup-cli", line 256, in <module>
wa.login(login, password)
File "/var/www/homecontrol/whatsapp/Examples/ListenerClient.py", line 61, in login
raw_input()
EOFError: EOF when reading a line
Alles anzeigen
Line 61 ist
Zitat
Das ist meine ListenerClient.py Datei.
'''
Copyright (c) <2012> Tarek Galal <tare2.galal@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'''
import os
import datetime, sys
import commands
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.sys.path.insert(0,parentdir)
if sys.version_info >= (3, 0):
raw_input = input
from Yowsup.connectionmanager import YowsupConnectionManager
class WhatsappListenerClient:
def __init__(self, keepAlive = False, sendReceipts = False):
self.sendReceipts = sendReceipts
connectionManager = YowsupConnectionManager()
connectionManager.setAutoPong(keepAlive)
self.signalsInterface = connectionManager.getSignalsInterface()
self.methodsInterface = connectionManager.getMethodsInterface()
self.signalsInterface.registerListener("message_received", self.onMessageReceived)
self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
self.signalsInterface.registerListener("disconnected", self.onDisconnected)
self.cm = connectionManager
#Login on whatsapp server
def login(self, username, password):
#Save username and password for reconnect
self.username = username
self.password = password
self.methodsInterface.call("auth_login", (username, password))
while True:
raw_input()
#Reconnect function for use in case of disconnection
def reconnect(self):
self.methodsInterface.call("auth_login", (self.username, self.password))
def onAuthSuccess(self, username):
print("Authed %s" % username)
self.methodsInterface.call("ready")
def onAuthFailed(self, username, err):
print("Auth Failed!")
#Disconnect incl reconnect
def onDisconnected(self, reason):
print("Disconnected because %s" %reason)
#Try to reconnect on disconnect because of "Zwangstrennung"
self.reconnect()
# Receive Message
def onMessageReceived(self, messageId, jid, messageContent, timestamp, wantsReceipt, pushName, isBroadCast):
formattedDate = datetime.datetime.fromtimestamp(timestamp).strftime('%d-%m-%Y %H:%M')
print("%s [%s]:%s"%(jid, formattedDate, messageContent))
#abfangen der jid des sender, der der die Nachricht schickt
self.sender_jid = jid
#Ueberpruefung das es sich um mein Handy handelt
if (jid[:13]=="49xxxxx") or (jid[:13]=="49yyyyy"):
# Message: Command to RPi
if messageContent.lower().startswith("cmd"):
cmd = messageContent.lower().replace("cmd ", "")
message = "Command '" + cmd + "' initialized"
self.methodsInterface.call("message_send", (jid, message))
os.system(cmd)
# Message: RPi Data
if "rpi data" in messageContent.lower():
temp = commands.getoutput('vcgencmd measure_temp')
volt = commands.getoutput('vcgencmd measure_volts')
core = commands.getoutput('vcgencmd measure_clock arm')
message = "RPi Werte: \n CPU Temp: %s \n CPU Spannung: %s \n CPU Takt: %s" %(temp,volt,core)
self.methodsInterface.call("message_send", (jid, message))
if wantsReceipt and self.sendReceipts:
self.methodsInterface.call("message_ack", (jid, messageId))
Alles anzeigen
Könnte mir vielleicht einer eine Hilfestellung bzw. einen Lösungsansatz geben? Das wäre super.
Danke im Voraus.
Sven