summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2010-03-28 12:27:59 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2010-03-28 12:27:59 +0000
commit203c9f80ece1e3de17b6c23bcae730f68d4b90fa (patch)
tree53d64893a65d579862651ddcd6fde595c6a810d6
parent94af8fbd907d32e5d95ef94ad0761945584c7472 (diff)
downloadebus-alt-203c9f80ece1e3de17b6c23bcae730f68d4b90fa.tar.gz
ebus-alt-203c9f80ece1e3de17b6c23bcae730f68d4b90fa.zip
egg
git-svn-id: http://10.2.2.13/svn/common/ebus@1613 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
-rw-r--r--dist/ebus-0.2-py2.5.eggbin0 -> 8227 bytes
-rw-r--r--doc/sample_log (renamed from sample_log)0
-rw-r--r--ebus/__init__.py (renamed from ebustest.py)25
-rw-r--r--examples/dumper.py11
-rw-r--r--setup.py24
5 files changed, 44 insertions, 16 deletions
diff --git a/dist/ebus-0.2-py2.5.egg b/dist/ebus-0.2-py2.5.egg
new file mode 100644
index 0000000..63184b9
--- /dev/null
+++ b/dist/ebus-0.2-py2.5.egg
Binary files differ
diff --git a/sample_log b/doc/sample_log
index d75193b..d75193b 100644
--- a/sample_log
+++ b/doc/sample_log
diff --git a/ebustest.py b/ebus/__init__.py
index 30bce73..d0d3497 100644
--- a/ebustest.py
+++ b/ebus/__init__.py
@@ -139,6 +139,7 @@ class EbusPacket(object):
return self.description()['name']
def __str__(self):
+ #XXX self.length only in subclasses
return "<%-18s name=\"%-15s\" source=\"%s\" destination=\"%s\" primary=0x%x secondary=0x%x length=0x%x %s>" % \
(self.__class__.__name__, self.name(), getDsc(self.source), getDsc(self.destination), \
self.primary_command, self.secondary_command, self.length, \
@@ -156,7 +157,9 @@ class EbusPacket(object):
desc = self.description()
if not desc or not desc.has_key('format'):
return dict()
- return dict( map(lambda name: (name, desc['format'][name].value(self.data) ), desc['format'].keys()) )
+ else:
+ #XXX self.data only in subclass
+ return dict( map(lambda name: (name, desc['format'][name].value(self.data) ), desc['format'].keys()) )
class EbusMasterMaster(EbusPacket):
def __init__(self, source, destination, primary_command, secondary_command, data):
@@ -204,7 +207,7 @@ class EbusReader(asynchat.async_chat):
def _parse(self,data):
if len(data) < 2:
- print "GAGA"
+ print >>sys.stderr, "GAGA"
return
source = ord(data[0])
destination = ord(data[1])
@@ -212,11 +215,11 @@ class EbusReader(asynchat.async_chat):
sourceDevice = filter(lambda dev: dev['address'] == source, deviceDescription)
destinationDevice = filter(lambda dev: dev['address'] == destination, deviceDescription)
if len(sourceDevice) == 0 or len(destinationDevice) == 0:
- print "Unbekanntes Paket: source=%x destination=%x" % (source, destination)
+ print >>sys.stderr, "Unbekanntes Paket: source=%x destination=%x" % (source, destination)
return
if len(data) < 9:
- print "Unvollständige Daten"
+ print >>sys.stderr, "Unvollständige Daten"
return
primaryCommand = ord(data[2])
@@ -242,18 +245,8 @@ class EbusReader(asynchat.async_chat):
p = EbusBroadcast(source, destination, primaryCommand, secondaryCommand, payload)
self.handle_ebus(p)
else:
- print "KOMISCHES ZEUG"
+ print >>sys.stderr, "KOMISCHES ZEUG"
return
def handle_ebus(self,ebus_packet):
- print "unhandled ebus_packet"
-
-
-
-class MyEbusReader(EbusReader):
- def handle_ebus(self,ebus_packet):
- if ebus_packet.values() != dict():
- print ebus_packet
-
-MyEbusReader()
-asyncore.loop()
+ print >>sys.stderr, "unhandled ebus_packet"
diff --git a/examples/dumper.py b/examples/dumper.py
new file mode 100644
index 0000000..01d2ede
--- /dev/null
+++ b/examples/dumper.py
@@ -0,0 +1,11 @@
+# -*- coding:utf8 -*-
+import asyncore
+from ebus import EbusReader
+
+class MyEbusReader(EbusReader):
+ def handle_ebus(self,ebus_packet):
+ if ebus_packet.values() != dict():
+ print ebus_packet
+
+MyEbusReader()
+asyncore.loop()
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..78f3a97
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+from setuptools import setup
+
+setup(
+ name='ebus',
+ version='0.2',
+ description='Ebus/TCP Library',
+ author='xapek.org',
+ author_email='ebus@xapek.org',
+ url='http://xapek.org',
+ packages=['ebus'],
+ install_requires=[],
+ long_description="""""",
+ classifiers=[
+# "License :: OSI Approved :: MIT License",
+ "Programming Language :: Python",
+# "Topic :: Internet",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+ "Intended Audience :: Developers",
+# "Development Status :: 4 - Beta",
+ ]
+ )
+