Skip to content

Commit

Permalink
Merge branch 'release-1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cstrassburg committed Aug 20, 2016
2 parents bbb720a + a8d3ac0 commit f6c65b3
Show file tree
Hide file tree
Showing 291 changed files with 64,515 additions and 1,222 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
/visu
/doc/build
/doc/sphinx_bootstrap_theme


# Unittest and coverage reports
.cache
.coverage
.tox
nosetests.xml
*.egg-info
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ An example is shown below
class_path = plugins.onewire
[visu]
class_name = WebSocket
class_path = plugins.visu
class_path = plugins.visu_websocket
[smartvisu]
class_name = SmartVisu
class_path = plugins.visu_smartvisu
smartvisu_dir = /var/www/html/smartVISU
[cli]
class_name = CLI
Expand Down
153 changes: 62 additions & 91 deletions bin/smarthome.py

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ For an git introduction to git see: [http://gitimmersion.com/](http://gitimmersi

It you want to publish your plugin, get an [github account](https://github.com/users) as soon as possible.

### Usefull commands
### Useful commands
* __list changes__ since the release with the tag VERSIONTAG: `git log --pretty=format:"%s" <VERSIONTAG>..HEAD`
* __undo commit__ with the id XXXIDXXX: `git reset --hard XXXIDXXX && git push origin develop --force`
* __copy commit__ to current branch: `git cherry-pick <commit>`

Follow the [commit Atom Feed](https://github.com/mknx/smarthome/commits/develop.atom)
Follow the [commit Atom Feed](https://github.com/smarthomeNG/smarthome/commits/develop.atom)

### Global settings
* only push the current branch (not all): `git config --global push.default current`
Expand All @@ -25,13 +25,13 @@ The repositry consist of three main branches:

* __master__: it contains the stable/release code
* __develop__: is the branch where new features and plugins are merged into
* __gh-pages__: this branch contains the SmartHome.py website hostet at: [http://mknx.github.io/smarthome/](http://mknx.github.io/smarthome/)
* __gh-pages__: this branch contains the SmartHomeNG.py website

The branch setup is based on [this model](http://nvie.com/posts/a-successful-git-branching-model/).

### Getting the Source
* you could fork the repository on github or
* get the repository: `git clone git://github.com/mknx/smarthome.git`
* get the repository: `git clone https://github.com/smarthomeNG/smarthome.git
* create your own (local) branch (from develop) `git checkout -b myplugin develop`

## Python Version
Expand All @@ -41,7 +41,7 @@ You should only use Python =< 3.2 methods. If not make it clear in the documenta
Your code should conform to [pep 8](http://www.python.org/dev/peps/pep-0008/). (I'm ignoring "E501 line too long".)

## Start Coding
* __copy__ the skeleton directory: `cp -r plugins/skeleton plugins/myplugin`
* __copy__ the sample plugin directory: `cp -r dev/sample_plugin plugins/myplugin`
* __edit__ the main file: `vi plugins/myplugin/__init__.py`

### Tools
Expand Down Expand Up @@ -71,19 +71,19 @@ In your plugin directory should be a __README.md__ (from the skeleton directory)
* changes to plugins from other developers must be checked with the developer.

### Fork
* Goto [SmartHome Repo](https://github.com/mknx/smarthome) logged in with your username/password.
* Goto [SmartHome Repo](https://github.com/smarthomeNG/smarthome) logged in with your username/password.
* Click on 'fork' in the right upper corner.
* Change to your Terminal and enter `git clone https://USER:[email protected]/USER/smarthome`
* Checkout the develop branch `git checkout develop`
* Change/create a file.
* Add the file `git add FILE`
* Commit the changes with a usefull comment: 'git commit'
* Push your changes to your repository: `git pull && git push`
* Create a pull request on github: base: mknx/develop compare: USER/develop
* Create a pull request on github: base: smarthomeNG/develop compare: USER/develop


### Merge
If you think your code is ready for prime time send me a __pull request via github__ or an [email](mailto:[email protected]) with the code.
If you think your code is ready for prime time send me a __pull request via github__

Acitve commiters could merge the myplugin branch into develop with:

Expand All @@ -96,7 +96,7 @@ Acitve commiters could merge the myplugin branch into develop with:
If you have problems pushing, you could check the repo git config. Mine looks like this:
<pre>
[remote "origin"]
url = git@github.com:mknx/smarthome.git
url = https://github.com/smarthomeNG/smarthome
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
Expand Down
19 changes: 7 additions & 12 deletions dev/skeleton.py → dev/license_header.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
#!/usr/bin/env python3
# vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab
#########################################################################
# Copyright 2014 <AUTHOR> <EMAIL>
# Copyright 2016 <name>
#########################################################################
# This file is part of SmartHome.py. http://smarthome.sourceforge.net/
# This file is part of SmartHomeNG
# https://github.com/smarthomeNG/smarthome
# http://knx-user-forum.de/
#
# SmartHome.py is free software: you can redistribute it and/or modify
# SmartHomeNG is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SmartHome.py is distributed in the hope that it will be useful,
# SmartHomeNG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SmartHome.py. If not, see <http://www.gnu.org/licenses/>.
# along with SmartHomeNG If not, see <http://www.gnu.org/licenses/>.
#########################################################################

import logging

logger = logging.getLogger('')

if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
4 changes: 2 additions & 2 deletions plugins/skeleton/README.md → dev/sample_plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# My Plugin
# My Plugin <- put the name of your plugin here

# Requirements

Expand Down Expand Up @@ -34,7 +34,7 @@ List and describe the possible item attributes.

### my_attr

Description of the attribute...
Description of the attribute(s)...

### my_attr2

Expand Down
135 changes: 135 additions & 0 deletions dev/sample_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/usr/bin/env python3
# vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab
#########################################################################
# Copyright 2016 <AUTHOR> <EMAIL>
#########################################################################
# This file is part of SmartHomeNG.
#
# Basic Skeleton for new plugins to run with SmartHomeNG version 1.1
# upwards.
#
# SmartHomeNG is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SmartHomeNG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SmartHomeNG. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################

import logging
from lib.model.smartplugin import SmartPlugin

# todo
# instead of PluginName you name your plugin
class PluginClassName(SmartPlugin):
"""
Main class of the Plugin. Does all plugin specific stuff and provides
the update functions for the items
"""

# todo
# change ALLOW_MULTIINSTANCE to true if your plugin will support multiple instances (seldom)
ALLOW_MULTIINSTANCE = False

# todo
# set the version number of you plugin
# a.b should reflect the version of SmartHomeNG that is first compatible with this
# plugin
# c is the version of your plugin
# a sample plugin with a 23rd revision starting for SmartHomeNG 1.2 would be '1.2.23'
PLUGIN_VERSION = "a.b.c"


def __init__(self, sh, *args, **kwargs):
"""
Initalizes the plugin. The parameters describe for this method are pulled from the entry in plugin.conf.
:param sh: The instance of the smarthome object, save it for later references
"""
# attention:
# if your plugin runs standalone, sh will likely be None so do not rely on it later or check it within your code

self._sh = sh
self.logger = logging.getLogger(__name__) # get a unique logger for the plugin and provide it internally

# todo:
# put any initialization for your plugin here


def run(self):
"""
Run method for the plugin
"""
self.logger.debug("run method called")
self.alive = True
# if you want to create child threads, do not make them daemon = True!
# They will not shutdown properly. (It's a python bug)


def stop(self):
"""
Stop method for the plugin
"""
self.logger.debug("stop method called")
self.alive = False

def parse_item(self, item):
"""
Default plugin parse_item method. Is called when the plugin is initialized.
Selects each item corresponding to its attribute keywords and adds it to an internal array
:param item: The item to process.
"""
# todo
# change 'foo_itemtag' into your attribute name
# you might also check for other attribute names if your plugin supports multiple attributes
if self.has_iattr(item.conf, 'foo_itemtag'):
self.logger.debug("parse item: {0}".format(item))

def parse_logic(self, logic):
"""
Default plugin parse_logic method
"""
if 'xxx' in logic.conf:
# self.function(logic['name'])
pass

def update_item(self, item, caller=None, source=None, dest=None):
"""
Write items values
:param item: item to be updated towards the plugin
:param caller: if given it represents the callers name
:param source: if given it represents the source
:param dest: if given it represents the dest
"""
# todo
# change 'foo_itemtag' into your attribute name
if item():
if self.has_iattr(item.conf, 'foo_itemtag'):
self.logger("update_item ws called with item '{}' from caller '{}', source '{}' and dest '{}'".format(item, caller, source, dest))
pass

# PLEASE CHECK CODE HERE. The following was in the old skeleton.py and seems not to be
# valid any more
# # todo here: change 'plugin' to the plugin name
# if caller != 'plugin':
# logger.info("update item: {0}".format(item.id()))


"""
If the plugin is run standalone e.g. for test purposes the follwing code will be executed
"""
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s')
# todo
# change PluginClassName appropriately
PluginClassName(None).run()

32 changes: 18 additions & 14 deletions doc/source/conf.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import os

sys.path.insert(0, os.path.abspath('../../'))
import doc.sphinx_bootstrap_theme
#import doc.sphinx_bootstrap_theme
import sphinx_bootstrap_theme


# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -27,23 +29,23 @@
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8-sig'
source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'SmartHome.py'
copyright = u'2011-2013, Marcus Popp'
project = u'SmartHomeNG'
copyright = u'2011-2013, Marcus Popp; since 2016 SmartHomeNG Team'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = 1.0
version = '1.2'
# The full version, including alpha/beta/rc tags.
release = 1.0
release = '1.2'
#release = sphinx_bootstrap_theme.__version__

# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down Expand Up @@ -91,7 +93,7 @@
# documentation.
html_theme_options = {
# Navigation bar title. (Default: ``project`` value)
'navbar_title': "SmartHome.py",
'navbar_title': "SmartHomeNG",

# Tab name for entire site. (Default: "Site")
'navbar_site_name': "Site",
Expand All @@ -106,11 +108,12 @@
'navbar_links': [
("Install", "install"),
("Config", "config"),
("Logics", "logic"),
("Plugins", "plugin"),
("Bugs", "https://github.com/mknx/smarthome/issues?state=open", True),
("Wiki", "https://github.com/mknx/smarthome/wiki", True),
("Download", "https://github.com/mknx/smarthome/releases", True),
("Items", "items"),
("Logics", "logics"),
("Plugins", "plugins"),
("Bugs", "https://github.com/smarthomeNG/smarthome/issues?state=open", True),
("Wiki", "https://github.com/smarthomeNG/smarthome/wiki", True),
("Download", "https://github.com/smarthomeNG/smarthome/releases", True),
],

# Global TOC depth for "site" navbar tab. (Default: 1)
Expand Down Expand Up @@ -168,7 +171,8 @@
# Add any paths that contain custom themes here, relative to this directory.
# ``get_html_theme_path`` returns a list, so you can concatenate with
# any other theme directories you would like.
html_theme_path = doc.sphinx_bootstrap_theme.get_html_theme_path()
#html_theme_path = doc.sphinx_bootstrap_theme.get_html_theme_path()
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
Expand All @@ -189,7 +193,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static", "img"]
html_static_path = ["_static", "_static/img"]

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Expand Down
Loading

0 comments on commit f6c65b3

Please sign in to comment.