Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	bin/shngversion.py
  • Loading branch information
msinn committed Feb 13, 2022
2 parents 985af52 + 57a9ae4 commit 8133e71
Show file tree
Hide file tree
Showing 94 changed files with 4,179 additions and 2,273 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Thumbs.db
# Don't check in built documentation
/doc/user/build
/doc/user/source/plugins_doc
!/doc/user/source/plugins_doc/plugins_footer.rst
!/doc/user/source/plugins_doc/plugins_gateway_header.rst
!/doc/user/source/plugins_doc/plugins_interface_header.rst
!/doc/user/source/plugins_doc/plugins_protocol_header.rst
!/doc/user/source/plugins_doc/plugins_system_header.rst
!/doc/user/source/plugins_doc/plugins_unclassified_header.rst
!/doc/user/source/plugins_doc/plugins_all_header.rst

/doc/developer/build
/doc/developer/source/plugins_doc

Expand Down
35 changes: 21 additions & 14 deletions bin/shngversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
sys.path.append('..')

import plugins.__init__ as plugin_vers

from lib.utils import Version

# Update auf 1.3d wg. neuer item features on_update, on_change
# Update auf 1.3e wg. neuer logic features for visu_websocket
Expand Down Expand Up @@ -72,11 +72,14 @@
# Update auf 1.8.2a wg. Kennzeichnung des Stands als "nach dem v1.8.2 Release"
# Update auf 1.8.2b wg. Erweiterung des Item Loggings"
# Update auf 1.8.2c wg. Wegen Anpassungen an mem-logging / lib.log
# Update auf 1.8.2d Unterstützung für User-Functions
# Update auf 1.8.2d wg. Unterstützung für User-Functions

# Update auf 1.9.0 wg. Release
# Update auf 1.9a wg. Kennzeichnung des Stands als "nach dem v1.9.0 Release"

# Update auf 1.9.1 wg. Release

shNG_version = '1.9.0'
shNG_version = '1.9.1'
shNG_branch = 'master'

# ---------------------------------------------------------------------------------
Expand Down Expand Up @@ -115,17 +118,21 @@ def _get_git_data(sub='', printout=False):
# ---------------------------------------------------------------------------------

def get_shng_main_version():
return shNG_version
return Version.format( shNG_version )

def get_shng_plugins_version():
plgversion = get_plugins_version().split('-')[0]
return Version.format( plgversion )

def get_shng_version():
commit, commit_short, branch, describe = _get_git_data()
VERSION = get_shng_main_version()
if branch == 'master':
VERSION += '.'+branch+' ('+commit_short+')'
VERSION += '-'+branch+' ('+commit_short+')'
elif branch == 'manual':
VERSION += '.'+shNG_branch+' ('+branch+')'
VERSION += '-'+shNG_branch+' ('+branch+')'
else:
VERSION += '.'+commit_short+'.'+branch
VERSION += '-'+commit_short+'.'+branch
return VERSION

def get_shng_branch():
Expand All @@ -139,7 +146,7 @@ def get_shng_description():

def get_plugins_version():
commit, commit_short, branch, describe = _get_git_data('plugins')
VERSION = get_shng_main_version()
VERSION = Version.format( get_shng_main_version() )
try:
PLUGINS_VERSION = plugin_vers.plugin_release()
except:
Expand All @@ -150,16 +157,16 @@ def get_plugins_version():
PLUGINS_SOURCE_BRANCH = ''

if branch == 'master':
VERSION = PLUGINS_VERSION
VERSION += '.'+branch+' ('+commit_short+')'
VERSION = Version.format( PLUGINS_VERSION )
VERSION += '-'+branch+' ('+commit_short+')'
elif branch == 'manual':
VERSION = PLUGINS_VERSION
VERSION = Version.format( PLUGINS_VERSION )
if PLUGINS_SOURCE_BRANCH != '':
VERSION += '.'+PLUGINS_SOURCE_BRANCH
VERSION += '-'+PLUGINS_SOURCE_BRANCH
VERSION += ' ('+branch+')'
else:
VERSION = PLUGINS_VERSION
VERSION += '.'+commit_short+'.'+branch
VERSION = Version.format( PLUGINS_VERSION )
VERSION += '-'+commit_short+'.'+branch
return VERSION


Expand Down
26 changes: 19 additions & 7 deletions bin/smarthome.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,29 @@
from lib.shpypi import Shpypi
shpypi = Shpypi.get_instance()
if shpypi is None:
shpypi = Shpypi(base=BASE)
shpypi = Shpypi(base=BASE, version=VERSION)

core_reqs = shpypi.test_core_requirements(logging=False, pip3_command=args.pip3_command)
if core_reqs == 0:
print("Starting SmartHomeNG again...")
python_bin = sys.executable
if ' ' in python_bin:
python_bin = '"'+python_bin+'"'
command = python_bin + ' ' + os.path.join(BASE, 'bin', 'smarthome.py')
# if we didn't change the working dir (yet), for example...
# command = [python_bin] + sys.argv
command = [python_bin, os.path.join(BASE, 'bin', 'smarthome.py')]

# if started with parameter to stay in foreground, don't fork
if args.foreground or args.interactive or args.debug:
try:
# function call doesn't return; this process is replaced by the new one
os.execv(python_bin, [python_bin] + sys.argv)
except OSError as e:
print(f'Restart command {command} failed with error {e}')
exit(0)

try:
command.append('-r')
p = subprocess.Popen(command, shell=True)
except subprocess.SubprocessError as e:
print("Restart command '{}' failed with error {}".format(command,e))
Expand Down Expand Up @@ -199,7 +212,10 @@ def _reload_logics():

lib.backup.make_backup_directories(BASE)

if args.interactive:
if args.restart:
time.sleep(5)
lib.daemon.kill(PIDFILE, 30)
elif args.interactive:
MODE = 'interactive'
import code
import rlcompleter # noqa
Expand Down Expand Up @@ -234,10 +250,6 @@ def _reload_logics():
elif args.stop:
lib.daemon.kill(PIDFILE, 30)
exit(0)
elif args.restart:
time.sleep(5)
lib.daemon.kill(PIDFILE, 30)
pass
elif args.debug:
MODE = 'debug'
elif args.quiet:
Expand Down
70 changes: 36 additions & 34 deletions dev/sample_plugin/webif/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
<!-- set update_interval to a value > 0 (in milliseconds) to enable periodic data updates -->
{% set update_interval = 0 %}

<!--
Additional styles go into this block
-->
{% block pluginstyles %}
<style>
table th.value {
width: 100px;
}
</style>
{% endblock pluginstyles %}

<!--
Additional script tag for plugin specific javascript code go into this block
-->
Expand All @@ -14,10 +25,9 @@
if (dataSet === 'devices_info' || dataSet === null) {
var objResponse = JSON.parse(response);
myProto = document.getElementById(dataSet);
for (var device in objResponse) {
for (item in objResponse) {
/*
shngInsertText (device+'_source', objResponse[device]['source']);
shngInsertText (device+'_powerState', objResponse[device]['powerState']);
shngInsertText (item+'_value', objResponse[item]['value'], 'maintable');
*/
}
}
Expand All @@ -29,22 +39,23 @@
-->
<script>
$(document).ready( function () {
try
{
$('#<table_id>').DataTable( {
"paging": false,
fixedHeader: true
} );
$('#maintable').DataTable( {
"paging": false,
fixedHeader: true
} );
}
catch (e)
{
console.log("Datatable JS not loaded, showing standard table without reorder option")
}
});
/*
loading defaults from /modules/http/webif/gstatic/datatables/datatables.defaults.js
You can copy that file, put it in your plugin directory, rename the "bind" function and
trigger that function here instead of datatables_defaults if you want to change the behaviour.
Of course you can also overwrite defaults by putting the option declarations in {} below.
*/
$(window).trigger('datatables_defaults');
try
{
$('#maintable').DataTable( {} ); // put options into {} if needed
$('#<table_id>').DataTable( {} ); // delete or change name
}
catch (e)
{
console.log("Datatable JS not loaded, showing standard table without reorder option " + e)
}
});
</script>
{% endblock pluginscripts %}

Expand Down Expand Up @@ -113,30 +124,21 @@
{% block bodytab1 %}
<div class="container-fluid m-2">
{{ _('Hier kommt der Inhalt des Webinterfaces hin.') }}
<!--
Example table using datatables JS. Always use well-formed table formatting like
<table>
<thead>
<tr> <th></th><th></th>...</tr>
</thead>
<tbody>
<tr> <td></td><td></td>...</tr>
</tbody>
</table>
-->
<table id="maintable" class="table table-striped table-hover pluginList">

<!-- set id accordingly -->
<table id="maintable" class="table table-striped table-hover pluginList display">
<thead>
<tr>
<th>{{ _('Item') }}</th>
<th>{{ _('Wert') }}</th>
<th class="value">{{ _('Wert') }}</th>
</tr>
</thead>
<tbody>
{% for item in p.get_items() %}
{% if p.has_iattr(item.conf, '<plugin_attribute>') %}
<tr>
<td class="py-1">{{ item._path }}</td>
<td class="py-1">{{ item() }}</td>
<td class="py-1" id="{{ item._path }}">{{ item._path }}</td>
<td class="py-1" id="{{ item._path }}_value">{{ item() }}</td>
</tr>
{% endif %}
{% endfor %}
Expand Down
8 changes: 6 additions & 2 deletions doc/build_doc_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ if [ "${KEEP_REPO,,}" != "true" ]; then
fi
echo
echo Sollten die build Verzeichnisse bereits existieren, werden die alten
echo gebauten Versionen während des Skriptes gelöscht. Der Account unter dem s
echo diese Skript ausgeführt wird, muss Rechte zum anlegen von Verzeichnissen
echo gebauten Versionen während des Skriptes gelöscht. Der Account unter dem
echo dieses Skript ausgeführt wird, muss Rechte zum anlegen von Verzeichnissen
echo in \'$DIR\' haben.
echo
if [ "${GIT_CHECKOUT,,}" == "true" ]; then
Expand Down Expand Up @@ -171,6 +171,8 @@ if [ "${DOC,,}" == "developer" ] || [ "${DOC,,}" == "all" ]; then
make html || exit
echo
echo Bau der Entwickler-Dokumentation ist abgeschlossen!
echo
echo Die Startseite ist: \'${DIR}/user/build/html/index.html\'
fi

if [ "${DOC,,}" == "user" ] || [ "${DOC,,}" == "all" ]; then
Expand All @@ -185,6 +187,8 @@ if [ "${DOC,,}" == "user" ] || [ "${DOC,,}" == "all" ]; then
make html || exit
echo
echo Bau der Anwender-Dokumentation ist abgeschlossen!
echo
echo Die Startseite ist: \'${DIR}/user/build/html/index.html\'
fi


Expand Down
1 change: 1 addition & 0 deletions doc/build_plugin_config_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ def write_configfile(plg, configfile_dir, language='de'):
global docu_type
docu_type = start_dir.split('/')[-1:][0] # developer / user

print('Creating the configuration documentation pages for the plugins')
print('Start directory = '+start_dir)
print('Documentation type = '+docu_type)
print('Documentation language = '+language)
Expand Down
Loading

0 comments on commit 8133e71

Please sign in to comment.