Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
druciak authored and Krzysztof Goworek committed Nov 24, 2015
0 parents commit 74fe9f3
Show file tree
Hide file tree
Showing 13 changed files with 1,477 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>enigma2-plugin-openhab</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
10 changes: 10 additions & 0 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>

<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/enigma2-plugin-openhab/src</path>
</pydev_pathproperty>
</pydev_project>
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# enigma2-plugin-openhab
Simple openHAB client for Enigma2 platform
78 changes: 78 additions & 0 deletions po/openHAB.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-19 18:57+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: src/plugin.py:65
msgid "on"
msgstr ""

#: src/plugin.py:65
msgid "off"
msgstr ""

#: src/plugin.py:167
#, python-format
msgid ""
"Error loading sitemap: %s\n"
"Open settings window to configure connection parameters?"
msgstr ""

#: src/plugin.py:293
msgid "openHAB client"
msgstr ""

#: src/plugin.py:294
msgid "Simple openHAB client for Enigma2"
msgstr ""

#: src/setup.py:31
msgid "Host"
msgstr ""

#: src/setup.py:32
msgid "Port"
msgstr ""

#: src/setup.py:33
msgid "User"
msgstr ""

#: src/setup.py:34
msgid "Password"
msgstr ""

#: src/setup.py:35
msgid "Sitemap"
msgstr ""

#: src/setup.py:36
msgid "Enable debug"
msgstr ""

#: src/setup.py:41
#, python-format
msgid "Plugin: %(name)s , Version: %(version)s"
msgstr ""

#: src/setup.py:43
msgid "Cancel"
msgstr ""

#: src/setup.py:44
msgid "Save"
msgstr ""
82 changes: 82 additions & 0 deletions po/pl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: openHAB plugin, v1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-19 20:05+0100\n"
"PO-Revision-Date: 2015-11-19 20:12+0100\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.6\n"
"Last-Translator: \n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"Language: pl\n"
"X-Poedit-SourceCharset: UTF-8\n"

#: src/plugin.py:65
msgid "on"
msgstr "włączony"

#: src/plugin.py:65
msgid "off"
msgstr "wyłączony"

#: src/plugin.py:167
#, python-format
msgid ""
"Error loading sitemap: %s\n"
"Open settings window to configure connection parameters?"
msgstr ""
"Błąd podczas ładowania mapy: %s\n"
"Otworzyć okno ustawień aby skonfigurować parametry połączenia?"

#: src/plugin.py:293
msgid "openHAB client"
msgstr "Klient openHAB"

#: src/plugin.py:294
msgid "Simple openHAB client for Enigma2"
msgstr "Prosty klient openHAB dla platformy Enigma2"

#: src/setup.py:31
msgid "Host"
msgstr "Host"

#: src/setup.py:32
msgid "Port"
msgstr "Port"

#: src/setup.py:33
msgid "User"
msgstr "Użytkownik"

#: src/setup.py:34
msgid "Password"
msgstr "Hasło"

#: src/setup.py:35
msgid "Sitemap"
msgstr "Mapa"

#: src/setup.py:36
msgid "Enable debug"
msgstr "Włącz debug"

#: src/setup.py:41
#, python-format
msgid "Plugin: %(name)s , Version: %(version)s"
msgstr "Plugin: %(name)s , Wersja: %(version)s"

#: src/setup.py:43
msgid "Cancel"
msgstr "Anuluj"

#: src/setup.py:44
msgid "Save"
msgstr "Zapisz"
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from distutils.core import setup, Extension
import setup_translate

pkg = 'Extensions.openHAB'
setup (name = 'enigma2-plugin-extensions-openhab',
version = '0.1',
description = 'Simple openHAB client for Enigma2',
package_dir = {pkg: 'src'},
packages = [pkg],
package_data = {pkg: ['../LICENSE', '*.png', '../po/*/LC_MESSAGES/*.mo']},
cmdclass = setup_translate.cmdclass, # for translation
)
44 changes: 44 additions & 0 deletions setup_translate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Language extension for distutils Python scripts. Based on this concept:
# http://wiki.maemo.org/Internationalize_a_Python_application
from distutils import cmd
from distutils.command.build import build as _build
import glob
import os

class build_trans(cmd.Command):
description = 'Compile .po files into .mo files'
def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
s = 'po'
lang_domains = glob.glob(os.path.join(s, '*.pot'))
if len(lang_domains):
for lang in os.listdir(s):
if lang.endswith('.po'):
src = os.path.join(s, lang)
lang = lang[:-3]
destdir = os.path.join('build', 'lib', 'Extensions', 'openHAB', 'locale', lang, 'LC_MESSAGES')
if not os.path.exists(destdir):
os.makedirs(destdir)
for lang_domain in lang_domains:
lang_domain = lang_domain.rsplit('/', 1)[1]
dest = os.path.join(destdir, lang_domain[:-3] + 'mo')
print "Language compile %s -> %s" % (src, dest)
if os.system("msgfmt '%s' -o '%s'" % (src, dest)) != 0:
raise Exception, "Failed to compile: " + src
else:
print "we got no domain -> no translation was compiled"

class build(_build):
sub_commands = _build.sub_commands + [('build_trans', None)]
def run(self):
_build.run(self)

cmdclass = {
'build': build,
'build_trans': build_trans,
}
50 changes: 50 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- coding: UTF-8 -*-

from Components.config import config, ConfigSubsection, ConfigText, ConfigNumber, ConfigPassword, ConfigYesNo
from Components.Language import language
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
import os, gettext, time

PLUGIN_BASE = "openHAB"
PLUGIN_VERSION = "1.0"

LOG_FILE = "/tmp/%s.log" % PLUGIN_BASE

PluginLanguageDomain = PLUGIN_BASE
PluginLanguagePath = "Extensions/%s/locale" % PLUGIN_BASE

def localeInit():
gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))

def _(txt):
t = gettext.dgettext(PluginLanguageDomain, txt)
if t == txt:
print "[" + PluginLanguageDomain + "] fallback to default translation for ", txt
t = gettext.gettext(txt)
return t

def initLog():
try:
os.remove(LOG_FILE)
except OSError:
pass

def debug(message):
if config_root.debug.value:
with open(LOG_FILE, "aw") as f:
f.write(time.ctime() + ": " + message + "\n")

def initConfig():
config_root = config.plugins.openHAB = ConfigSubsection()
config_root.host = ConfigText(fixed_size=False)
config_root.port = ConfigNumber(8080)
config_root.user = ConfigText(fixed_size=False)
config_root.password = ConfigPassword()
config_root.sitemap = ConfigText(default="default", fixed_size=False)
config_root.refresh = ConfigNumber(3)
config_root.debug = ConfigYesNo(default=False)
return config_root

config_root = initConfig()
localeInit()
language.addCallback(localeInit)
Loading

0 comments on commit 74fe9f3

Please sign in to comment.