|
12 | 12 |
|
13 | 13 | from future.moves.html.entities import entitydefs
|
14 | 14 | from future.moves.urllib.parse import quote_plus, unquote_plus
|
15 |
| -from future.utils import iteritems, string_types, text_type |
| 15 | +from future.utils import iteritems, text_type |
16 | 16 |
|
17 | 17 | import xbmc
|
18 | 18 |
|
@@ -120,6 +120,16 @@ def log(s):
|
120 | 120 | ensure_ascii(s)), level=xbmc.LOGINFO)
|
121 | 121 |
|
122 | 122 |
|
| 123 | +def append_message(msg_list, msg): |
| 124 | + """ |
| 125 | + Add message with newline to existing formatted msg |
| 126 | + :param msg_list: list - contains title and content |
| 127 | + :param msg: message to append to content |
| 128 | + """ |
| 129 | + assert len(msg_list) == 2 |
| 130 | + msg_list[1] = '{0}\n{1}'.format(msg_list[1], msg) |
| 131 | + |
| 132 | + |
123 | 133 | def format_error_summary():
|
124 | 134 | """Format error summary
|
125 | 135 |
|
@@ -160,11 +170,8 @@ def format_dialog_message(msg, title=None):
|
160 | 170 | else:
|
161 | 171 | content = ["%s v%s" % (get_addon_name(), get_addon_version())]
|
162 | 172 |
|
163 |
| - # Force unicode to str |
164 |
| - if isinstance(msg, string_types): |
165 |
| - msg = str(msg).split('\n') |
166 |
| - |
167 |
| - return content + msg |
| 173 | + content.append(ensure_ascii(msg)) |
| 174 | + return content |
168 | 175 |
|
169 | 176 |
|
170 | 177 | def format_dialog_error(msg=None):
|
@@ -260,20 +267,22 @@ def is_valid_country(connection_info, message=None):
|
260 | 267 | if country_code:
|
261 | 268 | from aussieaddonscommon import countries
|
262 | 269 | country_name = countries.countries.get(country_code, country_code)
|
263 |
| - message.append('Your country is reported as %s, but this service ' |
264 |
| - 'is probably geo-blocked to Australia.' % |
265 |
| - country_name) |
| 270 | + append_message(message, |
| 271 | + 'Your country is reported as {0}, but this ' |
| 272 | + 'service is probably geo-blocked to ' |
| 273 | + 'Australia.'.format(country_name)) |
266 | 274 | xbmcgui.Dialog().ok(*message)
|
267 | 275 | return False
|
268 | 276 |
|
269 | 277 | if blacklisted_hostname:
|
270 |
| - message.append('VPN/proxy detected that has been blocked by this ' |
| 278 | + append_message(message, |
| 279 | + 'VPN/proxy detected that has been blocked by this ' |
271 | 280 | 'content provider.')
|
272 | 281 | xbmcgui.Dialog().ok(*message)
|
273 | 282 | return False
|
274 | 283 |
|
275 | 284 | if not is_valid_version():
|
276 |
| - message.append('Invalid version number for issue report. ') |
| 285 | + append_message(message, 'Invalid version number for issue report. ') |
277 | 286 | xbmcgui.Dialog().ok(*message)
|
278 | 287 | return False
|
279 | 288 |
|
@@ -335,10 +344,9 @@ def send_report(title, trace=None, connection_info=None):
|
335 | 344 | report_url = issue_reporter.report_issue(title, trace, connection_info)
|
336 | 345 |
|
337 | 346 | split_url = report_url.replace('/issue-reports', ' /issue-reports')
|
338 |
| - dialog_message(['Thanks! Your issue has been reported to: ', |
339 |
| - split_url, |
340 |
| - 'Please visit and describe the issue in order for ' |
341 |
| - 'us to assist.']) |
| 347 | + dialog_message('Thanks! Your issue has been reported to: {0}\n' |
| 348 | + 'Please visit and describe the issue in order ' |
| 349 | + 'for us to assist.'.format(split_url)) |
342 | 350 | return report_url
|
343 | 351 | except Exception:
|
344 | 352 | traceback.print_exc()
|
@@ -394,14 +402,16 @@ def handle_error(message):
|
394 | 402 | version = get_addon_version()
|
395 | 403 |
|
396 | 404 | if issue_reporter.is_not_latest_version(version, latest):
|
397 |
| - message.append('Your version of this add-on (v%s) is outdated. Please ' |
398 |
| - 'upgrade to the latest version: ' |
399 |
| - 'v%s' % (version, latest)) |
| 405 | + append_message(message, |
| 406 | + 'Your version of this add-on (v{0}) is outdated. ' |
| 407 | + 'Please upgrade to the latest version: ' |
| 408 | + 'v{1}'.format(version, latest)) |
400 | 409 | xbmcgui.Dialog().ok(*message)
|
401 | 410 | return
|
402 | 411 |
|
403 | 412 | if is_reportable:
|
404 |
| - message.append('Would you like to automatically ' |
| 413 | + append_message(message, |
| 414 | + 'Would you like to automatically ' |
405 | 415 | 'report this error?')
|
406 | 416 | if xbmcgui.Dialog().yesno(*message):
|
407 | 417 | issue_url = send_report(error, trace=trace,
|
|
0 commit comments