Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/aussieaddonscommon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,17 @@ def get_kodi_build():
try:
return xbmc.getInfoLabel("System.BuildVersion")
except Exception:
return
return None


def get_kodi_version():
"""Return the version number of Kodi"""
build = get_kodi_build()
version = build.split(' ')[0]
return version
if build:
version = build.split(' ')[0]
return version
else:
return '0'


def get_kodi_major_version():
Expand Down
10 changes: 10 additions & 0 deletions lib/tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,21 @@ def test_get_kodi_version(self, mock_info_label):
mock_info_label.return_value = fakes.BUILD_VERSION
self.assertEqual('18.2', utils.get_kodi_version())

@mock.patch('xbmc.getInfoLabel')
def test_get_kodi_version_none(self, mock_info_label):
mock_info_label.return_value = None
self.assertEqual('0', utils.get_kodi_version())

@mock.patch('xbmc.getInfoLabel')
def test_get_kodi_major_version(self, mock_info_label):
mock_info_label.return_value = fakes.BUILD_VERSION
self.assertEqual(18, utils.get_kodi_major_version())

@mock.patch('xbmc.getInfoLabel')
def test_get_kodi_major_version_blank(self, mock_info_label):
mock_info_label.return_value = ''
self.assertEqual(0, utils.get_kodi_major_version())

@mock.patch('xbmcaddon.Addon', fakes.FakeAddon)
@mock.patch('xbmc.log')
@mock.patch('xbmc.getCondVisibility')
Expand Down