Skip to content

Commit

Permalink
Fix sending kodi notifications using python3 (pymedusa#6399)
Browse files Browse the repository at this point in the history
* Fix sending kodi notifications using python3.

* removed pylint.

* Update kodi.py
  • Loading branch information
p0psicles authored and Thilas committed Jun 5, 2019
1 parent b12740a commit b7a777a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions medusa/notifiers/kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ def _notify_kodi(self, title, message, host=None, username=None, password=None,
'jsonrpc': '2.0',
'method': 'GUI.ShowNotification',
'params': {
'title': title.encode('utf-8'),
'message': message.encode('utf-8'),
'title': title,
'message': message,
'image': app.LOGO_URL,
},
'id': '1',
}
notify_result = self._send_to_kodi(command, cur_host, username, password, dest_app)
if notify_result and notify_result.get('result'):
result += cur_host + ':' + notify_result['result']
result += '{cur_host}:{notify_result}'.format(cur_host=cur_host, notify_result=notify_result['result'])
else:
if app.KODI_ALWAYS_ON or force:
log.warning(
Expand Down Expand Up @@ -180,7 +180,7 @@ def _send_to_kodi(command, host=None, username=None, password=None, dest_app='KO
"""Handle communication to KODI servers via JSONRPC.
Args:
command: Dictionary of field/data pairs, encoded via urllib and passed to the KODI JSON-RPC via HTTP
command: Dictionary of field/data pairs, passed to the KODI JSON-RPC via HTTP
host: KODI webserver host:port
username: KODI webserver username
password: KODI webserver password
Expand Down Expand Up @@ -227,7 +227,9 @@ def _send_to_kodi(command, host=None, username=None, password=None, dest_app='KO
log.warning(u'Connection error while trying to retrieve {0} API version for {1}: {2!r}',
dest_app, host, error)
return False
except Exception:
except Exception as error:
log.exception(u'An error occurred while trying to retrieve {0} API version for {1}: {2!r}',
dest_app, host, error)
return False

# parse the json result
Expand Down

0 comments on commit b7a777a

Please sign in to comment.