mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-26 20:26:41 +00:00
hdhomerun: allow running scripts from addon settings
This commit is contained in:
parent
0e933bb5b4
commit
2a2e30d38d
@ -1,3 +1,5 @@
|
|||||||
|
4.3.2
|
||||||
|
allow running scripts from addon settings
|
||||||
4.3.1
|
4.3.1
|
||||||
rebuild for addon api bump
|
rebuild for addon api bump
|
||||||
4.3.0
|
4.3.0
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
PKG_NAME="hdhomerun"
|
PKG_NAME="hdhomerun"
|
||||||
PKG_VERSION="4.3"
|
PKG_VERSION="4.3"
|
||||||
PKG_REV="1"
|
PKG_REV="2"
|
||||||
PKG_ARCH="any"
|
PKG_ARCH="any"
|
||||||
PKG_LICENSE="GPL"
|
PKG_LICENSE="GPL"
|
||||||
PKG_SITE="http://www.silicondust.com/products/hdhomerun/dvbt/"
|
PKG_SITE="http://www.silicondust.com/products/hdhomerun/dvbt/"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
# This file is part of OpenELEC - http://www.openelec.tv
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
# Copyright (C) 2009-2013 Stephan Raue (stephan@openelec.tv)
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
||||||
#
|
#
|
||||||
# OpenELEC is free software: you can redistribute it and/or modify
|
# OpenELEC is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -15,18 +15,3 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import xbmcaddon
|
|
||||||
|
|
||||||
__settings__ = xbmcaddon.Addon(id = 'driver.dvb.hdhomerun')
|
|
||||||
__cwd__ = __settings__.getAddonInfo('path')
|
|
||||||
__resources_lib__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'lib'))
|
|
||||||
__settings_xml__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'settings.xml'))
|
|
||||||
|
|
||||||
if __name__ == "__main__" and len(sys.argv) == 2 and sys.argv[1] == 'refresh_tuners':
|
|
||||||
sys.path.append(__resources_lib__)
|
|
||||||
from functions import refresh_hdhomerun_tuners
|
|
||||||
refresh_hdhomerun_tuners(__settings_xml__)
|
|
||||||
__settings__.openSettings()
|
|
||||||
|
32
packages/addons/driver/hdhomerun/source/resources/actions.py
Normal file
32
packages/addons/driver/hdhomerun/source/resources/actions.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
################################################################################
|
||||||
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
||||||
|
#
|
||||||
|
# OpenELEC 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 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenELEC 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 OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import xbmcaddon
|
||||||
|
|
||||||
|
__settings__ = xbmcaddon.Addon(id = 'driver.dvb.hdhomerun')
|
||||||
|
__cwd__ = __settings__.getAddonInfo('path')
|
||||||
|
__resources_lib__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'lib'))
|
||||||
|
__settings_xml__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'settings.xml'))
|
||||||
|
|
||||||
|
if len(sys.argv) == 2 and sys.argv[1] == 'refresh_tuners':
|
||||||
|
sys.path.append(__resources_lib__)
|
||||||
|
from functions import refresh_hdhomerun_tuners
|
||||||
|
refresh_hdhomerun_tuners(__settings_xml__)
|
||||||
|
__settings__.openSettings()
|
@ -37,36 +37,39 @@ def _usage(this_file):
|
|||||||
return """SYNOPSIS: pretty print an XML document
|
return """SYNOPSIS: pretty print an XML document
|
||||||
USAGE: python %s <filename> \n""" % this_file
|
USAGE: python %s <filename> \n""" % this_file
|
||||||
|
|
||||||
def _pprint_line(indent_level, line, width=100, output=_sys.stdout):
|
def _pprint_line(indent_level, line, width=100, output=_sys.stdout, ignore_contents = False):
|
||||||
if line.strip():
|
if line.strip():
|
||||||
start = ""
|
start = ""
|
||||||
number_chars = 0
|
number_chars = 0
|
||||||
for l in range(indent_level):
|
for l in range(indent_level):
|
||||||
start = start + " "
|
start = start + " "
|
||||||
number_chars = number_chars + 1
|
number_chars = number_chars + 1
|
||||||
try:
|
if not ignore_contents:
|
||||||
elem_start = _re.findall("(\<\W{0,1}\w+:\w+) ?", line)[0]
|
try:
|
||||||
elem_finished = _re.findall("([?|\]\]/]*\>)", line)[0]
|
elem_start = _re.findall("(\<\W{0,1}\w+:\w+) ?", line)[0]
|
||||||
#should not have *
|
elem_finished = _re.findall("([?|\]\]/|\-\-]*\>)", line)[0]
|
||||||
attrs = _re.findall("(\S*?\=\".*?\")", line)
|
#should not have *
|
||||||
output.write(start + elem_start)
|
attrs = _re.findall("(\S*?\=\".*?\")", line)
|
||||||
number_chars = len(start + elem_start)
|
output.write(start + elem_start)
|
||||||
for attr in attrs:
|
number_chars = len(start + elem_start)
|
||||||
if (attrs.index(attr) + 1) == len(attrs):
|
for attr in attrs:
|
||||||
number_chars = number_chars + len(elem_finished)
|
if (attrs.index(attr) + 1) == len(attrs):
|
||||||
if (number_chars + len(attr) + 1) > width:
|
number_chars = number_chars + len(elem_finished)
|
||||||
output.write("\n")
|
if (number_chars + len(attr) + 1) > width:
|
||||||
for i in range(len(start + elem_start) + 1):
|
output.write("\n")
|
||||||
|
for i in range(len(start + elem_start) + 1):
|
||||||
|
output.write(" ")
|
||||||
|
number_chars = len(start + elem_start) + 1
|
||||||
|
else:
|
||||||
output.write(" ")
|
output.write(" ")
|
||||||
number_chars = len(start + elem_start) + 1
|
number_chars = number_chars + 1
|
||||||
else:
|
output.write(attr)
|
||||||
output.write(" ")
|
number_chars = number_chars + len(attr)
|
||||||
number_chars = number_chars + 1
|
output.write(elem_finished + "\n")
|
||||||
output.write(attr)
|
except IndexError:
|
||||||
number_chars = number_chars + len(attr)
|
#give up pretty print this line
|
||||||
output.write(elem_finished + "\n")
|
output.write(start + line + "\n")
|
||||||
except IndexError:
|
else:
|
||||||
#give up pretty print this line
|
|
||||||
output.write(start + line + "\n")
|
output.write(start + line + "\n")
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +84,7 @@ def _get_next_elem(data):
|
|||||||
end_pos = data.find(">") + 1
|
end_pos = data.find(">") + 1
|
||||||
retval = data[start_pos:end_pos]
|
retval = data[start_pos:end_pos]
|
||||||
stopper = retval.rfind("/")
|
stopper = retval.rfind("/")
|
||||||
|
ignore_contents = False
|
||||||
if stopper < retval.rfind("\""):
|
if stopper < retval.rfind("\""):
|
||||||
stopper = -1
|
stopper = -1
|
||||||
single = (stopper > -1 and ((retval.find(">") - stopper) < (stopper - retval.find("<"))))
|
single = (stopper > -1 and ((retval.find(">") - stopper) < (stopper - retval.find("<"))))
|
||||||
@ -89,11 +93,19 @@ def _get_next_elem(data):
|
|||||||
ignore_question = retval.find("<?") > -1
|
ignore_question = retval.find("<?") > -1
|
||||||
|
|
||||||
if ignore_excl:
|
if ignore_excl:
|
||||||
|
ignore_contents = True
|
||||||
cdata = retval.find("<![CDATA[") > -1
|
cdata = retval.find("<![CDATA[") > -1
|
||||||
if cdata:
|
if cdata:
|
||||||
end_pos = data.find("]]>")
|
end_pos = data.find("]]>")
|
||||||
if end_pos > -1:
|
if end_pos > -1:
|
||||||
end_pos = end_pos + len("]]>")
|
end_pos = end_pos + len("]]>")
|
||||||
|
stopper = end_pos
|
||||||
|
else:
|
||||||
|
end_pos = data.find("-->")
|
||||||
|
if end_pos > -1:
|
||||||
|
end_pos = end_pos + len("-->")
|
||||||
|
stopper = end_pos
|
||||||
|
retval = data[start_pos:end_pos]
|
||||||
|
|
||||||
elif ignore_question:
|
elif ignore_question:
|
||||||
end_pos = data.find("?>") + len("?>")
|
end_pos = data.find("?>") + len("?>")
|
||||||
@ -101,11 +113,12 @@ def _get_next_elem(data):
|
|||||||
|
|
||||||
no_indent = ignore or single
|
no_indent = ignore or single
|
||||||
|
|
||||||
#print retval, end_pos, start_pos, stopper > -1, no_indent
|
|
||||||
return start_pos, \
|
return start_pos, \
|
||||||
end_pos, \
|
end_pos, \
|
||||||
stopper > -1, \
|
stopper > -1, \
|
||||||
no_indent
|
no_indent, \
|
||||||
|
ignore_contents
|
||||||
|
|
||||||
def get_pprint(xml, indent=4, width=80):
|
def get_pprint(xml, indent=4, width=80):
|
||||||
"""Returns the pretty printed xml """
|
"""Returns the pretty printed xml """
|
||||||
@ -117,6 +130,8 @@ def get_pprint(xml, indent=4, width=80):
|
|||||||
out = out()
|
out = out()
|
||||||
pprint(xml, output=out, indent=indent, width=width)
|
pprint(xml, output=out, indent=indent, width=width)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return out.output
|
return out.output
|
||||||
|
|
||||||
|
|
||||||
@ -126,7 +141,7 @@ def pprint(xml, output=_sys.stdout, indent=4, width=80):
|
|||||||
Use indent to select indentation level. Default is 4 """
|
Use indent to select indentation level. Default is 4 """
|
||||||
data = xml
|
data = xml
|
||||||
indent_level = 0
|
indent_level = 0
|
||||||
start_pos, end_pos, is_stop, no_indent = _get_next_elem(data)
|
start_pos, end_pos, is_stop, no_indent, ignore_contents = _get_next_elem(data)
|
||||||
while ((start_pos > -1 and end_pos > -1)):
|
while ((start_pos > -1 and end_pos > -1)):
|
||||||
_pprint_elem_content(indent_level, data[:start_pos].strip(),
|
_pprint_elem_content(indent_level, data[:start_pos].strip(),
|
||||||
output=output)
|
output=output)
|
||||||
@ -136,7 +151,8 @@ def pprint(xml, output=_sys.stdout, indent=4, width=80):
|
|||||||
_pprint_line(indent_level,
|
_pprint_line(indent_level,
|
||||||
data[:end_pos - start_pos],
|
data[:end_pos - start_pos],
|
||||||
width=width,
|
width=width,
|
||||||
output=output)
|
output=output,
|
||||||
|
ignore_contents=ignore_contents)
|
||||||
data = data[end_pos - start_pos:]
|
data = data[end_pos - start_pos:]
|
||||||
if not is_stop and not no_indent :
|
if not is_stop and not no_indent :
|
||||||
indent_level = indent_level + indent
|
indent_level = indent_level + indent
|
||||||
@ -144,7 +160,7 @@ def pprint(xml, output=_sys.stdout, indent=4, width=80):
|
|||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
start_pos, end_pos, is_stop, no_indent = _get_next_elem(data)
|
start_pos, end_pos, is_stop, no_indent, ignore_contents = _get_next_elem(data)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -11,6 +11,6 @@
|
|||||||
<category label="9000">
|
<category label="9000">
|
||||||
<setting type="sep" />
|
<setting type="sep" />
|
||||||
<setting id="ENABLE_TUNER_TYPES" type="bool" label="9005" default="true" />
|
<setting id="ENABLE_TUNER_TYPES" type="bool" label="9005" default="true" />
|
||||||
<setting label="9010" option="close" type="action" action="RunScript($ID, refresh_tuners)" />
|
<setting label="9010" option="close" type="action" id="refresh_tuners" action="RunScript($CWD/resources/actions.py, refresh_tuners)" />
|
||||||
</category>
|
</category>
|
||||||
</settings>
|
</settings>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user