Skip to content

Commit 328e70e

Browse files
Fix CI (#532)
1 parent 507db9d commit 328e70e

File tree

8 files changed

+45
-33
lines changed

8 files changed

+45
-33
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,24 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
os: [ ubuntu-latest ]
21-
python-version: [ '2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10' ]
21+
python-version: [ '2.7', '3.7', '3.8', '3.9', '3.10', '3.11' ]
22+
include:
23+
# End-of-life Python versions are not available anymore with ubuntu-latest
24+
- os: ubuntu-20.04
25+
python-version: '3.5'
26+
- os: ubuntu-20.04
27+
python-version: '3.6'
2228
steps:
2329
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
2430
uses: actions/checkout@v2
2531

2632
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v2
33+
uses: actions/setup-python@v3
2834
with:
2935
python-version: ${{ matrix.python-version }}
3036
- name: Install dependencies
3137
run: |
3238
sudo apt-get install gettext
33-
sudo pip install coverage --install-option="--install-scripts=/usr/bin"
3439
python -m pip install --upgrade pip
3540
pip install -r requirements.txt
3641
- name: Run tox

lib/inputstreamhelper/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _get_lib_version(path):
110110

111111
def _has_inputstream(self):
112112
"""Checks if selected InputStream add-on is installed."""
113-
data = jsonrpc(method='Addons.GetAddonDetails', params=dict(addonid=self.inputstream_addon))
113+
data = jsonrpc(method='Addons.GetAddonDetails', params={'addonid': self.inputstream_addon})
114114
if 'error' in data:
115115
log(3, '{addon} is not installed.', addon=self.inputstream_addon)
116116
return False
@@ -120,7 +120,7 @@ def _has_inputstream(self):
120120

121121
def _inputstream_enabled(self):
122122
"""Returns whether selected InputStream add-on is enabled.."""
123-
data = jsonrpc(method='Addons.GetAddonDetails', params=dict(addonid=self.inputstream_addon, properties=['enabled']))
123+
data = jsonrpc(method='Addons.GetAddonDetails', params={'addonid': self.inputstream_addon, 'properties': ['enabled']})
124124
if data.get('result', {}).get('addon', {}).get('enabled'):
125125
log(0, '{addon} {version} is enabled.', addon=self.inputstream_addon, version=self._inputstream_version())
126126
return True
@@ -130,7 +130,7 @@ def _inputstream_enabled(self):
130130

131131
def _enable_inputstream(self):
132132
"""Enables selected InputStream add-on."""
133-
data = jsonrpc(method='Addons.SetAddonEnabled', params=dict(addonid=self.inputstream_addon, enabled=True))
133+
data = jsonrpc(method='Addons.SetAddonEnabled', params={'addonid': self.inputstream_addon, 'enabled': True})
134134
if 'error' in data:
135135
return False
136136
return True
@@ -232,7 +232,7 @@ def install_widevine(self):
232232
@cleanup_decorator
233233
def install_widevine_from(self):
234234
"""Install Widevine from a given URL or file."""
235-
if yesno_dialog(None, localize(30066)): # download resource with widevine from url? no means specify local
235+
if yesno_dialog(None, localize(30066)): # download resource with widevine from url? no means specify local
236236
result = dl_extract_widevine(get_setting("image_url"), backup_path())
237237
if not result:
238238
return result
@@ -255,7 +255,6 @@ def install_widevine_from(self):
255255

256256
return False
257257

258-
259258
@staticmethod
260259
def remove_widevine():
261260
"""Removes Widevine CDM"""

lib/inputstreamhelper/kodiutils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ def set_setting_bool(key, value):
231231

232232
def get_global_setting(key):
233233
"""Get a Kodi setting"""
234-
result = jsonrpc(method='Settings.GetSettingValue', params=dict(setting=key))
234+
result = jsonrpc(method='Settings.GetSettingValue', params={'setting': key})
235235
return result.get('result', {}).get('value')
236236

237237

238238
def get_current_window_id():
239239
"""Get current window id"""
240-
result = jsonrpc(method='GUI.GetProperties', params=dict(properties=['currentwindow']))
240+
result = jsonrpc(method='GUI.GetProperties', params={'properties': ['currentwindow']})
241241
if result.get('error'):
242242
return None
243243
return result.get('result', {}).get('currentwindow').get('id')
@@ -276,13 +276,13 @@ def get_proxies():
276276

277277
proxy_types = ['http', 'socks4', 'socks4a', 'socks5', 'socks5h']
278278

279-
proxy = dict(
280-
scheme=proxy_types[httpproxytype] if 0 <= httpproxytype < 5 else 'http',
281-
server=get_global_setting('network.httpproxyserver'),
282-
port=get_global_setting('network.httpproxyport'),
283-
username=get_global_setting('network.httpproxyusername'),
284-
password=get_global_setting('network.httpproxypassword'),
285-
)
279+
proxy = {
280+
'scheme': proxy_types[httpproxytype] if 0 <= httpproxytype < 5 else 'http',
281+
'server': get_global_setting('network.httpproxyserver'),
282+
'port': get_global_setting('network.httpproxyport'),
283+
'username': get_global_setting('network.httpproxyusername'),
284+
'password': get_global_setting('network.httpproxypassword'),
285+
}
286286

287287
if proxy.get('username') and proxy.get('password') and proxy.get('server') and proxy.get('port'):
288288
proxy_address = '{scheme}://{username}:{password}@{server}:{port}'.format(**proxy)
@@ -295,7 +295,7 @@ def get_proxies():
295295
else:
296296
return None
297297

298-
return dict(http=proxy_address, https=proxy_address)
298+
return {'http': proxy_address, 'https': proxy_address}
299299

300300

301301
def log(level=0, message='', **kwargs):

lib/inputstreamhelper/widevine/widevine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def latest_available_widevine_from_repo():
180180
cdm_url = config.WIDEVINE_DOWNLOAD_URL.format(version=cdm_version, os=cdm_os, arch=cdm_arch)
181181
http_status = http_head(cdm_url)
182182
if http_status == 200:
183-
available_cdms.append(dict(version=cdm_version, url=cdm_url))
183+
available_cdms.append({'version': cdm_version, 'url': cdm_url})
184184
return available_cdms[-1]
185185

186186

tests/checkchromeos.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
from lib.inputstreamhelper.config import CHROMEOS_RECOVERY_ARM_HWIDS
88

99

10+
class OutdatedException(Exception):
11+
"""Is thrown when InputStreamHelper configuration should be updated."""
12+
13+
def __init__(self, message):
14+
self.message = message
15+
super(OutdatedException, self).__init__(self.message)
16+
17+
1018
def get_devices():
1119
"""Get Chrome OS devices as json object"""
1220
url = 'https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices'
@@ -107,7 +115,7 @@ def check_hwids():
107115
if item not in CHROMEOS_RECOVERY_ARM_HWIDS:
108116
messages.append('{} is missing, please add it to inputstreamhelper config'.format(item))
109117
if messages:
110-
raise Exception(messages)
118+
raise OutdatedException(messages)
111119

112120
smallest = get_smallest()
113121
hwid = smallest.get('hwidmatch').strip('^.*-').split(' ')[0]

tests/xbmc.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,21 @@ def executeJSONRPC(jsonrpccommand):
195195
ret.append(executeJSONRPC(json.dumps(action)))
196196
return json.dumps(ret)
197197

198-
ret = dict(id=command.get('id'), jsonrpc='2.0', result='OK')
198+
ret = {'id': command.get('id'), 'jsonrpc': '2.0', 'result': 'OK'}
199199
if command.get('method').startswith('Input'):
200200
pass
201201
elif command.get('method') == 'Player.Open':
202202
pass
203203
elif command.get('method') == 'Settings.GetSettingValue':
204204
key = command.get('params').get('setting')
205-
ret.update(result=dict(value=settings.get(key)))
205+
ret.update(result={'value': settings.get(key)})
206206
elif command.get('method') == 'Addons.GetAddonDetails':
207207
if command.get('params', {}).get('addonid') == 'script.module.inputstreamhelper':
208-
ret.update(result=dict(addon=dict(enabled='true', version='0.3.5')))
208+
ret.update(result={'addon': {'enabled': 'true', 'version': '0.3.5'}})
209209
else:
210-
ret.update(result=dict(addon=dict(enabled='true', version='1.2.3')))
210+
ret.update(result={'addon': {'enabled': 'true', 'version': '1.2.3'}})
211211
elif command.get('method') == 'Textures.GetTextures':
212-
ret.update(result=dict(textures=[dict(cachedurl="", imagehash="", lasthashcheck="", textureid=4837, url="")]))
212+
ret.update(result={'textures': [{'cachedurl': '', 'imagehash': '', 'lasthashcheck': '', 'textureid': 4837, 'url': ''}]})
213213
elif command.get('method') == 'Textures.RemoveTexture':
214214
pass
215215
elif command.get('method') == 'JSONRPC.NotifyAll':
@@ -223,7 +223,7 @@ def executeJSONRPC(jsonrpccommand):
223223
)
224224
else:
225225
log("executeJSONRPC does not implement method '{method}'".format(**command), LOGERROR)
226-
return json.dumps(dict(error=dict(code=-1, message='Not implemented'), id=command.get('id'), jsonrpc='2.0'))
226+
return json.dumps({'error': {'code': -1, 'message': 'Not implemented'}, 'id': command.get('id'), 'jsonrpc': '2.0'})
227227
return json.dumps(ret)
228228

229229

@@ -264,7 +264,7 @@ def log(msg, level=0):
264264
if level in (4, 5, 6, 7):
265265
color1 = '\033[31;1m'
266266
if level in (6, 7):
267-
raise Exception(msg)
267+
raise ValueError(msg)
268268
elif level in (2, 3):
269269
color1 = '\033[33;1m'
270270
elif level == 0:

tests/xbmcaddon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, id=ADDON_ID): # pylint: disable=redefined-builtin
1919

2020
def getAddonInfo(self, key):
2121
"""A working implementation for the xbmcaddon Addon class getAddonInfo() method"""
22-
stub_info = dict(id=self.id, name=self.id, version='2.3.4', type='kodi.inputstream', profile='special://userdata', path='special://userdata')
22+
stub_info = {'id': self.id, 'name': self.id, 'version': '2.3.4', 'type': 'kodi.inputstream', 'profile': 'special://userdata', 'path': 'special://userdata'}
2323
# Add stub_info values to ADDON_INFO when missing (e.g. path and profile)
2424
addon_info = dict(stub_info, **ADDON_INFO)
2525
return addon_info.get(self.id, stub_info).get(key)

tests/xbmcextra.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def uri_to_path(uri):
4040

4141
def read_addon_xml(path):
4242
"""Parse the addon.xml and return an info dictionary"""
43-
info = dict(
44-
path='./', # '/storage/.kodi/addons/plugin.video.vrt.nu',
45-
profile='special://userdata', # 'special://profile/addon_data/plugin.video.vrt.nu/',
46-
type='xbmc.python.pluginsource',
47-
)
43+
info = {
44+
'path': './', # '/storage/.kodi/addons/plugin.video.vrt.nu',
45+
'profile': 'special://userdata', # 'special://profile/addon_data/plugin.video.vrt.nu/',
46+
'type': 'xbmc.python.pluginsource',
47+
}
4848

4949
tree = ET.parse(path)
5050
root = tree.getroot()

0 commit comments

Comments
 (0)