summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/views.py
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-05-30 16:10:59 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-02 08:24:05 +0100
commit2b362f63428bdd221d82141bb1615ee8950e40b3 (patch)
tree109f6da6a09317927c2adbd9a16dbc5bf9078f5c /bitbake/lib/toaster/toastergui/views.py
parent2de58c97a5e7d9c0687f66da291c6dc3d37a755a (diff)
downloadpoky-2b362f63428bdd221d82141bb1615ee8950e40b3.tar.gz
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 <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py9
1 files changed, 6 insertions, 3 deletions
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):
200 return None 200 return None
201 201
202def _redirect_parameters(view, g, mandatory_parameters, *args, **kwargs): 202def _redirect_parameters(view, g, mandatory_parameters, *args, **kwargs):
203 import urllib 203 try:
204 from urllib import unquote, urlencode
205 except ImportError:
206 from urllib.parse import unquote, urlencode
204 url = reverse(view, kwargs=kwargs) 207 url = reverse(view, kwargs=kwargs)
205 params = {} 208 params = {}
206 for i in g: 209 for i in g:
207 params[i] = g[i] 210 params[i] = g[i]
208 for i in mandatory_parameters: 211 for i in mandatory_parameters:
209 if not i in params: 212 if not i in params:
210 params[i] = urllib.unquote(str(mandatory_parameters[i])) 213 params[i] = unquote(str(mandatory_parameters[i]))
211 214
212 return redirect(url + "?%s" % urllib.urlencode(params), permanent = False, **kwargs) 215 return redirect(url + "?%s" % urlencode(params), permanent = False, **kwargs)
213 216
214class RedirectException(Exception): 217class RedirectException(Exception):
215 def __init__(self, view, g, mandatory_parameters, *args, **kwargs): 218 def __init__(self, view, g, mandatory_parameters, *args, **kwargs):