KNX and KNXnet/IP implementation in Python - python

I am looking high and low for anything related to KNX implementation in Python, especially KNXnet/IP. So far I couldn't find anything. I know there are few projects written in Java but I thought I'd give it a shot asking here before I start porting code from other languages.
Also, does anyone know of any free documentation of the KNX standard, its data structures and KNXnet/IP? The official documentation from the KNX association is ridiculously expensive, especially for something supposed to be an "open" standard.
thanks

The KNX association have released the Falcon Runtime Developer kit but I think you can only get it if you are a KNX member. it doesnt supports Python but hey, its something i guess.
in regards to the documentation I could probably help.
is there a PM function on this site or something to give me your emails address?

There is the open-source BCUSDK software stack for KNX which has a C-based system daemon (eibd) with clients (Unix and TCP-socket based) for multiple languages (Python is one). I've written the Ruby and Lua client libraries as well, and I'm using it for day-to-day hacking with KNX.
Also, there is OpenRemote which has lots of information on KNXnet/IP and some Java classes that could get you started, if you wanted to, from scratch.

You might want to have a look a this (if by that time you are still looking for such a library) : https://github.com/leadrien/knxnet
This allows me to command KNX devices through an IP/KNX interface pretty well.
Alexandre

Meanwhile there is an open source Python 3 implementation of KNX IP https://github.com/XKNX/xknx
The documentation of the protocol can be downloaded after (free) registration from https://my.knx.org

Related

Which language to use for writing an admin console à la webmin?

We have an in house developed web-based admin console that uses a combination of C CGI and Perl scripts to administer our mail server stack. Of late we have been thinking of cleaning up the code (well, replacing most of it), making the implementation more secure, and improving the overall behavior.
I don't have much programming knowledge, but I use Ruby on and off (mainly for writing erb templates), and hence was thinking of using ruby/rails for developing such an app (off-duty for now, I also need to learn stuff !).
Before blindly picking up a language though, what would you folks suggest ? Please let me know if this is too vague a question, I'll try to supply more information, if needed.
Have you considered writing your applications as Webmin modules?
You get a lot of stuff for free when you do so (users and groups, tons of security features, a pretty big variety of helper functions related to config files, and tons of existing code for most aspects of a UNIX/Linux system). You also get a lot of stuff for nearly free, like action logging, packages and updates via wbm or apt or yum, an online help system, etc.
There are some cons, as well. It's an old codebase, so it has some clunky bits in the API among other places. A lot of the old modules can be a bit hard to grok if you're not an old-school Perl programmer. But, it's a well-maintained codebase, and it's been banged on by millions of users for over a dozen years. It's pretty robust. The UI isn't beautiful, but it is relatively theme-able, and if you're distributing a minimized version it becomes easier to customize the UI.
I suspect you can be up and running a lot faster than starting from scratch or using most existing frameworks that aren't targeted specifically to building systems management interfaces the way Webmin is.
Also, it's BSD licensed, so you can do whatever you want with it, including building a custom commercial app with it (hundreds of companies have done so over the years).
If you already know a bit of ruby, then there's no reason not to use that.
If you're interested specifically in learning another language, then what you're trying to do could be done in pretty much any language/framework, it's just a matter of which one you want to learn.
Without knowing much about your existing application I'd say that this effectively boils down to "which language do you like to work with?".
Python and Ruby are both mature languages with ample library infrastructure. They also boast popular, similar web application frameworks namely Django and Ruby-on-Rails respectively.
Since you are porting an existing Perl app(lets) it may be worthwhile to note that Ruby is relatively more similar to Perl. Not surprising given that Ruby was influenced "primarily by Perl, Smalltalk, Eiffel and Lisp".
django has a nice admin interface

python - good places to check out example prog / code online?

there is a year old, similar question - but in case there have been changes afoot:
i'm an intermediate c++ programmer just starting out on python, post some online tuts etc i can do some basic pythoneering, but was wondering if there are good places i can look online for simple(ish) --pref console based-- code that i can learn from, ideally with some sort of commentary.
anything come to mind?
thanks
The standard library is an excellent place to the start. It's maintained by the core python team and is of high quality with a lot of interesting idioms. I'd recommend the newer modules since they don't have much backward compatibility cruft and are more representative of the language as it is now. The older ones were written for earlier versions of Python and have some restrictions when it comes to API changes etc.
The list of modules in the standard library is described at http://docs.python.org/library/. You can go through it and decide which one you want to look at (area of interest etc.).
Their sources are viewable at the mercurial repo here http://hg.python.org/cpython/file/d7e85ddb1336/Lib (as of today). These are for the mainline 2.6 release. You can also checkout the repo and browse it on your local machine.
You can also start up your interpreter, import a module (say os) and do a print os.__file__ to see where the source file is if you want to look at the code in your local editor.
ActiveState Recipes is a good source for all kinds of Python scripts. But if you want to learn the basics of Python, you might just want to look at the standard library that ships with Python ("lib" directory").
i came across This The other day, Probably you can learn some python basics and have a laugh too!
Anyways, look at the libs as they said above, they are very useful
If you enjoy riddles:
www.pythonchallenge.com
If you're an intermediate C++ programmer, you're already equipped to handle to programming concepts. I like it because it gives me a reason to learn each part of the language, without being mundane 'Hello World' tasks.
However, some of the riddles are pretty tough and/or unrelated to programming. Either way, doing the first few will probably be enough to get your confidence up with Python syntax.

Docs for the internals of CPython Implementation

I am currently in the process of making an embedded system port of the CPython 3.0 Python interpreter and I'm particularly interested in any references or documentation that provides details about the design and structure of code for Release 3.0 or even about any of the 2.x releases.
One useful document I have found so far is this informational PEP on the implementation - which is a good overview - but is still pretty high level. Hoping to come across something that gives [much] more detail on more of the modules or perhaps even covers something about porting considerations.
There's the documentation for the C API, which is essentially the API for the internals of Python. It won't cover porting details, though. The code itself is fairly well documented. You might try reading in and around the area you'll need to modify.
Most of the documentation is stored in the minds of various core developers. :) A good resource for you would be the #python-dev IRC channel on freenode where many of them hang out.
There's also some scattered information on the Python wiki.

Best continuously updated resource about python web "plumbing"

I'm a programmer in Python who works on web-applications. I know a fair bit about the application level. But not so much about the underlying "plumbing" which I find myself having to configure or debug.
I'm thinking of everything from using memcached to flup, fcgi, WSGI etc.
When looking for information about these, online, Google typically delivers older-documents (eg. tutorials from before 2007), fragments of problems that may or may not have been resolved etc.
Are there any good comprehensive and up-to-date resources to learn about how to put together a modern, high-performance server? One that explains both principles of the architecture and the actual packages?
Buy this. http://www.amazon.com/Scalable-Internet-Architectures-Developers-Library/dp/067232699X
General info about highly efficient web architecture: http://highscalability.com/
Interesting Python related articles: http://www.onlamp.com/python/
Printed magazine: http://pythonmagazine.com/
Zope is a still evolving framework, written in Python and is documented online. For a start, see Zope Concepts and Architecture. Like other Python based web frameworks, the source is your best reference.
Note that Zope is not easy to grasp, and is different from frameworks like Django.
You can use this terminology to limit search results to the past year:
http://www.tech-recipes.com/rx/2860/google_how_to_access_filter_by_date_dropdown_box/

Python Applications: Can You Secure Your Code Somehow?

If there is truly a 'best' way, what is the best way to ship a python app and ensure people can't (easily) reverse engineer your algorithms/security/work in general?
If there isn't a 'best' way, what are the different options available?
Background:
I love coding in Python and would love to release more apps with it. One thing that I wonder about is the possibility of people circumventing any licensing code I put in, or being able to just rip off my entire source base. I've heard of Py2Exe and similar applications, but I'm curious if there are 'preferred' ways of doing it, or if this problem is just a fact of life.
Security through obscurity never works. If you must use a proprietary license, enforce it through the law, not half-baked obfuscation attempts.
If you're worried about them learning your security (e.g. cryptography) algorithm, the same applies. Real, useful, security algorithms (like AES) are secure even though the algorithm is fully known.
Even if you use a compiled language like C# or Java, people can perform reverse engineering if they are motivated and technically competent. Obfuscation is not a reliable protection against this.
You can add prohibition against reverse-engineering to your end-user license agreement for your software. Most proprietary companies do this. But that doesn't prevent violation, it only gives you legal recourse.
The best solution is to offer products and services in which the user's access to read your code does not harm your ability to sell your product or service. Base your business on service provided, or subscription to periodic updates to data, rather than the code itself.
Example: Slashdot actually makes their code for their website available. Does this harm their ability to run their website? No.
Another remedy is to set your price point such that the effort to pirate your code is more costly than simply buying legitimate licenses to use your product. Joel Spolsky has made a recommendation to this effects in his articles and podcasts.
Shipping a commercial mac desktop app in Python, we do exactly as described in the other answers; protect yourself by law with a decent EULA, not by obfuscating.
We have never had any troubles with people reverse engineering our code. And if we do, I feel confident we can take legal action. So yes, it's a fact of life. But one that is not too hard to live with. Just get a decent lawyer that writes a decent EULA.
The word you're looking for is obfuscate. A quick google reveals:
http://www.lysator.liu.se/~astrand/projects/pyobfuscate/
but:
a) If copyright infringement becomes a problem, then the law is on your side (as long as you include the appropriate copyright notices in all files).
b) It's also possible to make a profit on open source applications if you're clever about it.
c) If you want your Intellectual Property to be truly secure, then the only answer is to not let anyone have it in the first place: Write your application as a web app, (I recommend using django) and only your web hosting provider has access to your code.
py2exe
On windows py2exe is one way of shipping code to end-users, py2exe bundles the python interpreter, the necessary dlls and your code compiled to python bytecode.
Here are the python bytecode instructions to get some clue what it looks like:
http://www.python.org/doc/2.5.2/lib/bytecodes.html
Or you can use dis to disassemble some pyc/pyo files.
So, using py2exe is similar to distributing compiled python (pyc/pyo) files.
Shedskin C++ compiler
The Shedskin compiler compiles a subset of python to C++ which you can compile to native code using any compiler.
pypy
I don't know about PyPy too much. According to their docs Pypy is able to generate C code.

Categories

Resources