Skip to contentSkip to conversation

toaster: Fix adding of bitbake variables containing ':'

PATCH In review Alexander Egorenkov 3 participants 3 messages Aug 23, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: Fix adding of bitbake variables containing ':'

This fix is a backport from toaster-next.

Krogoth Toaster is unable to add a variable containing ':' and fails with the following error message:

error on request:
too many values to unpack
Traceback (most recent call last):
File "bitbake/lib/toaster/toastergui/views.py", line 2171, in xhr_configvaredit
variable, value = t.spli(":")
ValueError: too many values to unpack.

[YOCTO #10170]

---
 bitbake/lib/toaster/toastergui/views.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
bitbake/lib/toaster/toastergui/views.py +3 -2
index bd5bf63..2b714dc 100755
@@ -2164,11 +2164,12 @@ if True:
     def xhr_configvaredit(request, pid):
         try:
             prj = Project.objects.get(id = pid)
+            max_split=1
             # add conf variables
             if 'configvarAdd' in request.POST:
                 t=request.POST['configvarAdd'].strip()
                 if ":" in t:
-                    variable, value = t.split(":")
+                    variable, value = t.split(":", max_split)
                 else:
                     variable = t
                     value = ""
@@ -2178,7 +2179,7 @@ if True:
             if 'configvarChange' in request.POST:
                 t=request.POST['configvarChange'].strip()
                 if ":" in t:
-                    variable, value = t.split(":")
+                    variable, value = t.split(":", max_split)
                 else:
                     variable = t
                     value = ""
Signature · 1 line
2.9.3
#1 lore raw
Quoted 13 lines · On 23/08/2016 10:57, "[email protected] on behalf of Alexander…

This fix is a backport from toaster-next.

Krogoth Toaster is unable to add a variable containing ':' and fails with the following error message:

error on request:
too many values to unpack
Traceback (most recent call last):
File "bitbake/lib/toaster/toastergui/views.py", line 2171, in xhr_configvaredit
variable, value = t.spli(":")
ValueError: too many values to unpack.

Quoted 1 line

[YOCTO #10170]

This works for me.

Thanks!

Belén

Quoted 42 lines

---
bitbake/lib/toaster/toastergui/views.py | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
bitbake/lib/toaster/toastergui/views.py +3 -2
index bd5bf63..2b714dc 100755
@@ -2164,11 +2164,12 @@ if True:
    def xhr_configvaredit(request, pid):
        try:
            prj = Project.objects.get(id = pid)
+            max_split=1
            # add conf variables
            if 'configvarAdd' in request.POST:
                t=request.POST['configvarAdd'].strip()
                if ":" in t:
-                    variable, value = t.split(":")
+                    variable, value = t.split(":", max_split)
                else:
                    variable = t
                    value = ""
@@ -2178,7 +2179,7 @@ if True:
            if 'configvarChange' in request.POST:
                t=request.POST['configvarChange'].strip()
                if ":" in t:
-                    variable, value = t.split(":")
+                    variable, value = t.split(":", max_split)
                else:
                    variable = t
                    value = ""
Signature · 7 lines
2.9.3

-- 
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster
#2 lore raw
In reply to Alexander Egorenkov
Quoted 38 lines · Alexander Egorenkov

This fix is a backport from toaster-next.

Krogoth Toaster is unable to add a variable containing ':' and fails with the following error message:

error on request:
too many values to unpack
Traceback (most recent call last):
File "bitbake/lib/toaster/toastergui/views.py", line 2171, in xhr_configvaredit
variable, value = t.spli(":")
ValueError: too many values to unpack.

[YOCTO #10170]

---
 bitbake/lib/toaster/toastergui/views.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
bitbake/lib/toaster/toastergui/views.py +2 -1
index bd5bf63..2b714dc 100755
@@ -2164,11 +2164,12 @@ if True:
     def xhr_configvaredit(request, pid):
         try:
             prj = Project.objects.get(id = pid)
+            max_split=1
             # add conf variables
             if 'configvarAdd' in request.POST:
                 t=request.POST['configvarAdd'].strip()
                 if ":" in t:
-                    variable, value = t.split(":")
+                    variable, value = t.split(":", max_split)
                 else:
                     variable = t
                     value = ""

bitbake/lib/toaster/toastergui/views.py if True: · line 2185

Quoted 8 lines
bitbake/lib/toaster/toastergui/views.py +1 -1
@@ -2178,7 +2179,7 @@ if True:
             if 'configvarChange' in request.POST:
                 t=request.POST['configvarChange'].strip()
                 if ":" in t:
-                    variable, value = t.split(":")
+                    variable, value = t.split(":", max_split)
                 else:
                     variable = t
                     value = ""

Would it be better to use 'variable, value = t.split(":", 1)' in both lines, i.e. without adding max_split variable?
It would be more readable in my opinion.

--
Regards,
Ed