summaryrefslogtreecommitdiff
path: root/ebus
diff options
context:
space:
mode:
Diffstat (limited to 'ebus')
-rw-r--r--ebus/__init__.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/ebus/__init__.py b/ebus/__init__.py
index 7b8c8ed..a435e76 100644
--- a/ebus/__init__.py
+++ b/ebus/__init__.py
@@ -3,11 +3,15 @@ import asynchat
import asyncore
import socket
import sys
+import logging
import os
from lxml import objectify
from lxml import etree
+logger = logging.getLogger("ebus.core")
+logger.setLevel(logging.INFO)
+
class UnknownPacketException(Exception):
pass
@@ -122,7 +126,7 @@ class EbusReader(asynchat.async_chat):
i = i + 1
if len(data) < 2:
- print "GAGA"
+ logger.critical("Daten Gaga")
return
source = ord(data[0])
sourceType = EbusPacket.address_to_type(source)
@@ -130,7 +134,7 @@ class EbusReader(asynchat.async_chat):
destinationType = EbusPacket.address_to_type(destination)
if len(data) < 9:
- print >>sys.stderr, "Unvollständige Daten"
+ logger.critical("Unvollständige Daten")
return
primaryCommand = ord(data[2])
@@ -154,15 +158,15 @@ class EbusReader(asynchat.async_chat):
self.handle_ebus(p)
elif sourceType == 'master' and destinationType == 'slave':
p = EbusMasterSlave(source, destination, primaryCommand, secondaryCommand, payload, None) #FIXME
- print >>sys.stderr, "SKIP MASTER-SLAVE"
+ logger.info("SKIP MASTER-SLAVE")
elif sourceType == 'master' and destinationType == 'broadcast':
p = EbusBroadcast(source, destination, primaryCommand, secondaryCommand, payload)
self.handle_ebus(p)
else:
- print >>sys.stderr, "SKIP source=%s sourceType=%s destination=%s destType=%s" % \
- (source, sourceType, destination, destinationType)
+ logger.warning("SKIP source=%s sourceType=%s destination=%s destType=%s" % \
+ (source, sourceType, destination, destinationType))
except UnknownPacketException,e:
print e
def handle_ebus(self,ebus_packet):
- print >>sys.stderr, "unhandled ebus_packet"
+ logger.critical("unhandled ebus_packet")