From 2b362f63428bdd221d82141bb1615ee8950e40b3 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Mon, 30 May 2016 16:10:59 +0300 Subject: bitbake: toaster: fix urllib imports Some functions have been moved from urllib to urllib.parse in python 3. Modifying the code to import unquote, urlencode and unquote_plus from urllib.parse if import from urllib fails should make it working on both python 2 and python 3. (Bitbake rev: b91aa29fa20befd9841678a727bb91100363518f) Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bitbake/lib/toaster/toastergui/views.py') diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 8e920f028a..05108975ae 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -200,16 +200,19 @@ def _verify_parameters(g, mandatory_parameters): return None def _redirect_parameters(view, g, mandatory_parameters, *args, **kwargs): - import urllib + try: + from urllib import unquote, urlencode + except ImportError: + from urllib.parse import unquote, urlencode url = reverse(view, kwargs=kwargs) params = {} for i in g: params[i] = g[i] for i in mandatory_parameters: if not i in params: - params[i] = urllib.unquote(str(mandatory_parameters[i])) + params[i] = unquote(str(mandatory_parameters[i])) - return redirect(url + "?%s" % urllib.urlencode(params), permanent = False, **kwargs) + return redirect(url + "?%s" % urlencode(params), permanent = False, **kwargs) class RedirectException(Exception): def __init__(self, view, g, mandatory_parameters, *args, **kwargs): -- cgit v1.2.3-54-g00ecf