Metainformationen zur Seite

Python - Develop plugins with Python

Very often LoxBerry Plugins are based on an existing script/software and only offer a WebInterface for simple configuration. Very often Python is used in the "Raspberry" world. Unfortunately, the core developers of LoxBerry do not like Python very much, this is why there exist no libraries for often used and needed tasks/functions like we developed for Perl or PHP.

But there's a simple workaround for Python (and maybe also other programming languages) to use the Perl library functions in your scripts. Perl commands and code snipplets can be executed on command line in a one liner. The output of this command can be stored in a Python variable.

Example: You would like to figure out your current plugin folder. This can be done with LoxBerry LoxBerry::System module. The Perl script would look like this:

use LoxBerry::System;
 
print $lbpplugindir;
 
exit;


This small script can be put into a one liner and stored in a variable in Python like this:

import os    
 
call = os.popen("perl -e 'use LoxBerry::System; print $lbpplugindir; exit;'").read()
 
print (call)


This way all Perl Module functions which create simple output as string can be used in your Python scripts.