def play(router, params): handle = router.session.handle try: url = api.playlist_url(router.session.token['token'], params['id'], params['hls_id']) xbmcplugin.setResolvedUrl(handle, True, xbmcgui.ListItem(path=url)) except api.ApiResponseError as e: xbmcplugin.setResolvedUrl(handle, False, xbmcgui.ListItem()) utils.show_error(e.error)
def wrapper(router, params): try: func(router, params) except (ApiRequestError, ApiResponseError) as e: utils.show_error(e.error) args = [router] if callback.func_code.co_argcount == 1 else [ router, params ] callback(*args)
def sign_in_sms(router, params): dialog = xbmcgui.Dialog() phone = dialog.input(_('label.phone_number'), type=xbmcgui.INPUT_ALPHANUM) if not phone: return router.redirect('root', 'index') token = router.session.token resp = api.sms_auth(token['token'], phone) if not resp['send_sms']: utils.show_error(resp) code = dialog.input(_('label.sms_code'), type=xbmcgui.INPUT_NUMERIC) if not code: return router.redirect('root', 'index') token = api.sms_check(token['token'], phone, resp['region'], resp['agr_id'], code) utils.write_file('token.json', token) router.redirect('root', 'index', token=token)
def test_show_error_default_ru(Dialog): utils.show_error({}) Dialog().ok.assert_called_with('Ошибка при запросе данных', 'Причина неизвестна')
def test_show_error_default_en(dialog): utils.show_error({}) dialog().ok.assert_called_with('Data request error', 'Unknown reason') utils.show_error({'header_ui': 'header1', 'message': 'message1'}) dialog().ok.assert_called_with('header1', 'Message1')