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
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
- pull_request
|
||||
- push
|
||||
jobs:
|
||||
tests:
|
||||
name: Kodi Add-on checker
|
||||
name: Addon checker
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
kodi-branch: [leia, matrix]
|
||||
steps:
|
||||
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
path: ${{ github.repository }}
|
||||
- name: Set up Python 3.8
|
||||
@ -27,14 +20,19 @@ jobs:
|
||||
python-version: 3.8
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get install libxml2-utils xmlstarlet
|
||||
sudo apt-get install xmlstarlet
|
||||
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
|
||||
run: awk '/export-ignore/ { print $1 }' .gitattributes | xargs rm -rf --
|
||||
working-directory: ${{ github.repository }}
|
||||
- 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 }}
|
||||
if: matrix.kodi-branch == 'matrix'
|
||||
- name: Run kodi-addon-checker
|
||||
|
37
.github/workflows/ci.yml
vendored
37
.github/workflows/ci.yml
vendored
@ -1,16 +1,10 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
- pull_request
|
||||
- push
|
||||
jobs:
|
||||
tests:
|
||||
name: Unit tests
|
||||
name: Add-on testing
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PYTHONIOENCODING: utf-8
|
||||
@ -33,26 +27,21 @@ jobs:
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
- name: Run pylint
|
||||
run: |
|
||||
make check-pylint
|
||||
run: make check-pylint
|
||||
- name: Run tox
|
||||
run: |
|
||||
make check-tox
|
||||
run: make check-tox
|
||||
- name: Check translations
|
||||
run: |
|
||||
make check-translations
|
||||
run: make check-translations
|
||||
- name: Run unit tests
|
||||
run: coverage run -m unittest discover
|
||||
env:
|
||||
ADDON_USERNAME: ${{ secrets.ADDON_USERNAME }}
|
||||
ADDON_PASSWORD: ${{ secrets.ADDON_PASSWORD }}
|
||||
run: |
|
||||
coverage run -m unittest discover
|
||||
- name: Run addon
|
||||
run: |
|
||||
coverage run -a tests/run.py /
|
||||
- name: Run add-on service
|
||||
run: |
|
||||
coverage run -a service_entry.py
|
||||
ADDON_USERNAME: ${{ secrets.ADDON_USERNAME }}
|
||||
- name: Run addon service
|
||||
run: coverage run -a service_entry.py
|
||||
env:
|
||||
ADDON_PASSWORD: ${{ secrets.ADDON_PASSWORD }}
|
||||
ADDON_USERNAME: ${{ secrets.ADDON_USERNAME }}
|
||||
- name: Upload code coverage to CodeCov
|
||||
uses: codecov/codecov-action@v1
|
||||
continue-on-error: true
|
||||
|
@ -3,11 +3,13 @@
|
||||
|
||||
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__':
|
||||
from sys import argv
|
||||
|
@ -181,3 +181,15 @@ msgstr ""
|
||||
msgctxt "#30831"
|
||||
msgid "Update local metadata now"
|
||||
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"
|
||||
msgid "Update local metadata now"
|
||||
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 xbmcaddon
|
||||
|
||||
ADDON = xbmcaddon.Addon()
|
||||
|
||||
|
||||
class KodiLogHandler(logging.StreamHandler):
|
||||
""" A log handler for Kodi """
|
||||
|
||||
def __init__(self):
|
||||
logging.StreamHandler.__init__(self)
|
||||
addon_id = xbmcaddon.Addon().getAddonInfo("id")
|
||||
formatter = logging.Formatter("[{}] [%(name)s] %(message)s".format(addon_id))
|
||||
formatter = logging.Formatter("[{}] [%(name)s] %(message)s".format(ADDON.getAddonInfo("id")))
|
||||
self.setFormatter(formatter)
|
||||
|
||||
def emit(self, record):
|
||||
@ -24,10 +25,16 @@ class KodiLogHandler(logging.StreamHandler):
|
||||
logging.CRITICAL: xbmc.LOGFATAL,
|
||||
logging.ERROR: xbmc.LOGERROR,
|
||||
logging.WARNING: xbmc.LOGWARNING,
|
||||
logging.INFO: xbmc.LOGINFO,
|
||||
logging.INFO: xbmc.LOGNOTICE,
|
||||
logging.DEBUG: xbmc.LOGDEBUG,
|
||||
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:
|
||||
xbmc.log(self.format(record), levels[record.levelno])
|
||||
except UnicodeEncodeError:
|
||||
|
@ -38,12 +38,12 @@ class Player:
|
||||
# We already have a resolved stream. Nice!
|
||||
# We don't need credentials for these streams.
|
||||
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:
|
||||
# Lookup the stream
|
||||
resolved_stream = self._resolve_stream(episode.uuid)
|
||||
_LOGGER.info('Resolved stream: %s', resolved_stream)
|
||||
_LOGGER.debug('Resolved stream: %s', resolved_stream)
|
||||
|
||||
if resolved_stream:
|
||||
titleitem = Menu.generate_titleitem(episode)
|
||||
|
@ -28,7 +28,7 @@ class BackgroundService(Monitor):
|
||||
|
||||
def run(self):
|
||||
""" Background loop for maintenance tasks """
|
||||
_LOGGER.info('Service started')
|
||||
_LOGGER.debug('Service started')
|
||||
|
||||
while not self.abortRequested():
|
||||
# Update every `update_interval` after the last update
|
||||
@ -39,12 +39,12 @@ class BackgroundService(Monitor):
|
||||
if self.waitForAbort(10):
|
||||
break
|
||||
|
||||
_LOGGER.info('Service stopped')
|
||||
_LOGGER.debug('Service stopped')
|
||||
|
||||
def onSettingsChanged(self): # pylint: disable=invalid-name
|
||||
""" Callback when a setting has 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()
|
||||
|
||||
# Refresh container
|
||||
|
@ -39,7 +39,7 @@ class AuthApi:
|
||||
self._refresh_token = data_json.get('refresh_token')
|
||||
self._expiry = int(data_json.get('expiry', 0))
|
||||
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):
|
||||
""" Get a valid token """
|
||||
|
@ -11,4 +11,8 @@
|
||||
<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)"/>
|
||||
</category>
|
||||
<category label="30880"> <!-- Expert -->
|
||||
<setting label="30881" type="lsep"/> <!-- Logging -->
|
||||
<setting label="30882" type="bool" id="debug_logging" default="false"/>
|
||||
</category>
|
||||
</settings>
|
||||
|
@ -270,7 +270,7 @@ class ListItem:
|
||||
class Window:
|
||||
"""A reimplementation of the xbmcgui Window"""
|
||||
|
||||
def __init__(self, windowId):
|
||||
def __init__(self, existingwindowId=-1):
|
||||
"""A stub constructor for the xbmcgui Window class"""
|
||||
return None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user