Add option for debug logging and fix CI (#27)
This commit is contained in:
parent
121ea8808f
commit
b5e36047f5
26
.github/workflows/addon-check.yml
vendored
26
.github/workflows/addon-check.yml
vendored
@ -1,24 +1,17 @@
|
|||||||
name: Kodi
|
name: Kodi
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
- pull_request
|
||||||
branches:
|
- push
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
name: Kodi Add-on checker
|
name: Addon checker
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
kodi-branch: [leia, matrix]
|
kodi-branch: [leia, matrix]
|
||||||
steps:
|
steps:
|
||||||
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
|
- uses: actions/checkout@v2
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
with:
|
||||||
path: ${{ github.repository }}
|
path: ${{ github.repository }}
|
||||||
- name: Set up Python 3.8
|
- name: Set up Python 3.8
|
||||||
@ -27,14 +20,19 @@ jobs:
|
|||||||
python-version: 3.8
|
python-version: 3.8
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install libxml2-utils xmlstarlet
|
sudo apt-get install xmlstarlet
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install kodi-addon-checker
|
# FIXME: Requires changes from xbmc/addon-check#217
|
||||||
|
#pip install kodi-addon-checker
|
||||||
|
pip install git+git://github.com/xbmc/addon-check.git@master
|
||||||
- name: Remove unwanted files
|
- name: Remove unwanted files
|
||||||
run: awk '/export-ignore/ { print $1 }' .gitattributes | xargs rm -rf --
|
run: awk '/export-ignore/ { print $1 }' .gitattributes | xargs rm -rf --
|
||||||
working-directory: ${{ github.repository }}
|
working-directory: ${{ github.repository }}
|
||||||
- name: Rewrite addon.xml for Matrix
|
- name: Rewrite addon.xml for Matrix
|
||||||
run: xmlstarlet ed -L -u '/addon/requires/import[@addon="xbmc.python"]/@version' -v "3.0.0" addon.xml
|
run: |
|
||||||
|
xmlstarlet ed -L -u '/addon/requires/import[@addon="xbmc.python"]/@version' -v "3.0.0" addon.xml
|
||||||
|
version=$(xmlstarlet sel -t -v 'string(/addon/@version)' addon.xml)
|
||||||
|
xmlstarlet ed -L -u '/addon/@version' -v "${version}+matrix.99" addon.xml
|
||||||
working-directory: ${{ github.repository }}
|
working-directory: ${{ github.repository }}
|
||||||
if: matrix.kodi-branch == 'matrix'
|
if: matrix.kodi-branch == 'matrix'
|
||||||
- name: Run kodi-addon-checker
|
- name: Run kodi-addon-checker
|
||||||
|
37
.github/workflows/ci.yml
vendored
37
.github/workflows/ci.yml
vendored
@ -1,16 +1,10 @@
|
|||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
- pull_request
|
||||||
branches:
|
- push
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
name: Unit tests
|
name: Add-on testing
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
PYTHONIOENCODING: utf-8
|
PYTHONIOENCODING: utf-8
|
||||||
@ -33,26 +27,21 @@ jobs:
|
|||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
- name: Run pylint
|
- name: Run pylint
|
||||||
run: |
|
run: make check-pylint
|
||||||
make check-pylint
|
|
||||||
- name: Run tox
|
- name: Run tox
|
||||||
run: |
|
run: make check-tox
|
||||||
make check-tox
|
|
||||||
- name: Check translations
|
- name: Check translations
|
||||||
run: |
|
run: make check-translations
|
||||||
make check-translations
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
|
run: coverage run -m unittest discover
|
||||||
env:
|
env:
|
||||||
ADDON_USERNAME: ${{ secrets.ADDON_USERNAME }}
|
|
||||||
ADDON_PASSWORD: ${{ secrets.ADDON_PASSWORD }}
|
ADDON_PASSWORD: ${{ secrets.ADDON_PASSWORD }}
|
||||||
run: |
|
ADDON_USERNAME: ${{ secrets.ADDON_USERNAME }}
|
||||||
coverage run -m unittest discover
|
- name: Run addon service
|
||||||
- name: Run addon
|
run: coverage run -a service_entry.py
|
||||||
run: |
|
env:
|
||||||
coverage run -a tests/run.py /
|
ADDON_PASSWORD: ${{ secrets.ADDON_PASSWORD }}
|
||||||
- name: Run add-on service
|
ADDON_USERNAME: ${{ secrets.ADDON_USERNAME }}
|
||||||
run: |
|
|
||||||
coverage run -a service_entry.py
|
|
||||||
- name: Upload code coverage to CodeCov
|
- name: Upload code coverage to CodeCov
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import, division, unicode_literals
|
from __future__ import absolute_import, division, unicode_literals
|
||||||
|
|
||||||
import xbmcaddon
|
from xbmcaddon import Addon
|
||||||
|
|
||||||
from resources.lib import kodiutils
|
from resources.lib import kodiutils, kodilogging
|
||||||
|
|
||||||
kodiutils.ADDON = xbmcaddon.Addon()
|
# Reinitialise ADDON every invocation to fix an issue that settings are not fresh.
|
||||||
|
kodiutils.ADDON = Addon()
|
||||||
|
kodilogging.ADDON = Addon()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from sys import argv
|
from sys import argv
|
||||||
|
@ -181,3 +181,15 @@ msgstr ""
|
|||||||
msgctxt "#30831"
|
msgctxt "#30831"
|
||||||
msgid "Update local metadata now"
|
msgid "Update local metadata now"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30880"
|
||||||
|
msgid "Expert"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30881"
|
||||||
|
msgid "Logging"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30882"
|
||||||
|
msgid "Enable debug logging"
|
||||||
|
msgstr ""
|
||||||
|
@ -182,3 +182,15 @@ msgstr "Vernieuw de lokale metdata automatisch in de achtergrond"
|
|||||||
msgctxt "#30831"
|
msgctxt "#30831"
|
||||||
msgid "Update local metadata now"
|
msgid "Update local metadata now"
|
||||||
msgstr "De lokale metadata nu vernieuwen"
|
msgstr "De lokale metadata nu vernieuwen"
|
||||||
|
|
||||||
|
msgctxt "#30880"
|
||||||
|
msgid "Expert"
|
||||||
|
msgstr "Expert"
|
||||||
|
|
||||||
|
msgctxt "#30881"
|
||||||
|
msgid "Logging"
|
||||||
|
msgstr "Logboek"
|
||||||
|
|
||||||
|
msgctxt "#30882"
|
||||||
|
msgid "Enable debug logging"
|
||||||
|
msgstr "Activeer debug logging"
|
||||||
|
@ -8,14 +8,15 @@ import logging
|
|||||||
import xbmc
|
import xbmc
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
|
|
||||||
|
ADDON = xbmcaddon.Addon()
|
||||||
|
|
||||||
|
|
||||||
class KodiLogHandler(logging.StreamHandler):
|
class KodiLogHandler(logging.StreamHandler):
|
||||||
""" A log handler for Kodi """
|
""" A log handler for Kodi """
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
logging.StreamHandler.__init__(self)
|
logging.StreamHandler.__init__(self)
|
||||||
addon_id = xbmcaddon.Addon().getAddonInfo("id")
|
formatter = logging.Formatter("[{}] [%(name)s] %(message)s".format(ADDON.getAddonInfo("id")))
|
||||||
formatter = logging.Formatter("[{}] [%(name)s] %(message)s".format(addon_id))
|
|
||||||
self.setFormatter(formatter)
|
self.setFormatter(formatter)
|
||||||
|
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
@ -24,10 +25,16 @@ class KodiLogHandler(logging.StreamHandler):
|
|||||||
logging.CRITICAL: xbmc.LOGFATAL,
|
logging.CRITICAL: xbmc.LOGFATAL,
|
||||||
logging.ERROR: xbmc.LOGERROR,
|
logging.ERROR: xbmc.LOGERROR,
|
||||||
logging.WARNING: xbmc.LOGWARNING,
|
logging.WARNING: xbmc.LOGWARNING,
|
||||||
logging.INFO: xbmc.LOGINFO,
|
logging.INFO: xbmc.LOGNOTICE,
|
||||||
logging.DEBUG: xbmc.LOGDEBUG,
|
logging.DEBUG: xbmc.LOGDEBUG,
|
||||||
logging.NOTSET: xbmc.LOGNONE,
|
logging.NOTSET: xbmc.LOGNONE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Map DEBUG level to LOGNOTICE if debug logging setting has been activated
|
||||||
|
# This is for troubleshooting only
|
||||||
|
if ADDON.getSetting('debug_logging') == 'true':
|
||||||
|
levels[logging.DEBUG] = xbmc.LOGNOTICE
|
||||||
|
|
||||||
try:
|
try:
|
||||||
xbmc.log(self.format(record), levels[record.levelno])
|
xbmc.log(self.format(record), levels[record.levelno])
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
|
@ -38,12 +38,12 @@ class Player:
|
|||||||
# We already have a resolved stream. Nice!
|
# We already have a resolved stream. Nice!
|
||||||
# We don't need credentials for these streams.
|
# We don't need credentials for these streams.
|
||||||
resolved_stream = episode.stream
|
resolved_stream = episode.stream
|
||||||
_LOGGER.info('Already got a resolved stream: %s', resolved_stream)
|
_LOGGER.debug('Already got a resolved stream: %s', resolved_stream)
|
||||||
|
|
||||||
if episode.uuid:
|
if episode.uuid:
|
||||||
# Lookup the stream
|
# Lookup the stream
|
||||||
resolved_stream = self._resolve_stream(episode.uuid)
|
resolved_stream = self._resolve_stream(episode.uuid)
|
||||||
_LOGGER.info('Resolved stream: %s', resolved_stream)
|
_LOGGER.debug('Resolved stream: %s', resolved_stream)
|
||||||
|
|
||||||
if resolved_stream:
|
if resolved_stream:
|
||||||
titleitem = Menu.generate_titleitem(episode)
|
titleitem = Menu.generate_titleitem(episode)
|
||||||
|
@ -28,7 +28,7 @@ class BackgroundService(Monitor):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
""" Background loop for maintenance tasks """
|
""" Background loop for maintenance tasks """
|
||||||
_LOGGER.info('Service started')
|
_LOGGER.debug('Service started')
|
||||||
|
|
||||||
while not self.abortRequested():
|
while not self.abortRequested():
|
||||||
# Update every `update_interval` after the last update
|
# Update every `update_interval` after the last update
|
||||||
@ -39,12 +39,12 @@ class BackgroundService(Monitor):
|
|||||||
if self.waitForAbort(10):
|
if self.waitForAbort(10):
|
||||||
break
|
break
|
||||||
|
|
||||||
_LOGGER.info('Service stopped')
|
_LOGGER.debug('Service stopped')
|
||||||
|
|
||||||
def onSettingsChanged(self): # pylint: disable=invalid-name
|
def onSettingsChanged(self): # pylint: disable=invalid-name
|
||||||
""" Callback when a setting has changed """
|
""" Callback when a setting has changed """
|
||||||
if self._has_credentials_changed():
|
if self._has_credentials_changed():
|
||||||
_LOGGER.info('Clearing auth tokens due to changed credentials')
|
_LOGGER.debug('Clearing auth tokens due to changed credentials')
|
||||||
self._auth.clear_tokens()
|
self._auth.clear_tokens()
|
||||||
|
|
||||||
# Refresh container
|
# Refresh container
|
||||||
|
@ -39,7 +39,7 @@ class AuthApi:
|
|||||||
self._refresh_token = data_json.get('refresh_token')
|
self._refresh_token = data_json.get('refresh_token')
|
||||||
self._expiry = int(data_json.get('expiry', 0))
|
self._expiry = int(data_json.get('expiry', 0))
|
||||||
except (IOError, TypeError, ValueError):
|
except (IOError, TypeError, ValueError):
|
||||||
_LOGGER.info('We could not use the cache since it is invalid or non-existent.')
|
_LOGGER.warning('We could not use the cache since it is invalid or non-existent.')
|
||||||
|
|
||||||
def get_token(self):
|
def get_token(self):
|
||||||
""" Get a valid token """
|
""" Get a valid token """
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<setting label="30829" type="bool" id="metadata_update" default="true" subsetting="true"/>
|
<setting label="30829" type="bool" id="metadata_update" default="true" subsetting="true"/>
|
||||||
<setting label="30831" type="action" action="RunPlugin(plugin://plugin.video.viervijfzes/metadata/update)"/>
|
<setting label="30831" type="action" action="RunPlugin(plugin://plugin.video.viervijfzes/metadata/update)"/>
|
||||||
</category>
|
</category>
|
||||||
|
<category label="30880"> <!-- Expert -->
|
||||||
|
<setting label="30881" type="lsep"/> <!-- Logging -->
|
||||||
|
<setting label="30882" type="bool" id="debug_logging" default="false"/>
|
||||||
|
</category>
|
||||||
</settings>
|
</settings>
|
||||||
|
@ -270,7 +270,7 @@ class ListItem:
|
|||||||
class Window:
|
class Window:
|
||||||
"""A reimplementation of the xbmcgui Window"""
|
"""A reimplementation of the xbmcgui Window"""
|
||||||
|
|
||||||
def __init__(self, windowId):
|
def __init__(self, existingwindowId=-1):
|
||||||
"""A stub constructor for the xbmcgui Window class"""
|
"""A stub constructor for the xbmcgui Window class"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user