From 1d88c9204672996bd096eed8be52973ab6fa93e3 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Mon, 15 Apr 2019 18:04:22 +0200
Subject: [PATCH] CI: can't make the data option to work properly, find an
 other way

---
 CI/check_twin_pipelines.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/CI/check_twin_pipelines.py b/CI/check_twin_pipelines.py
index fe6a149336..e32f14d196 100644
--- a/CI/check_twin_pipelines.py
+++ b/CI/check_twin_pipelines.py
@@ -29,16 +29,14 @@ import time
 Send a request to Gitlab and return the answer
 The request parameter is added after `project/:id/`
 """
-def GitlabRequest(request, project=53,data={}, token=''):
+def GitlabRequest(request, project=53, token=''):
   gitlab_url = "https://gitlab.orfeo-toolbox.org/api/v4/projects/"
   gitlab_url+= str(project) + '/' + request
-  params = None
-  if data:
-    params = urllib.parse.urlencode(data).encode('ascii')
-  gitlab_request = urllib.request.Request(gitlab_url)
+  myHeader = {}
   if token:
-    gitlab_request.add_header('PRIVATE-TOKEN' , token )
-  res = urllib.request.urlopen(gitlab_request, data=params)
+    myHeader = {'PRIVATE-TOKEN':token}
+  gitlab_request = urllib.request.Request(gitlab_url,headers=myHeader)
+  res = urllib.request.urlopen(gitlab_request)
   return json.loads(res.read().decode())
 
 """
@@ -76,7 +74,7 @@ if __name__ == "__main__":
       sys.exit(1)
     else:
       # No: cancel any previous "normal" pipeline on the same SHA1
-      jres = GitlabRequest('pipelines', project=env['CI_PROJECT_ID'], data={'sha':sha1}, token=env['K8S_SECRET_TWIN_PIPELINE'])
+      jres = GitlabRequest('pipelines?sha='+sha1, project=env['CI_PROJECT_ID'], token=env['K8S_SECRET_TWIN_PIPELINE'])
       for item in jres:
         if item["id"] < int(env['CI_PIPELINE_ID']) and item["status"] == "running":
           print("Cancel pipeline "+str(item["id"]))
-- 
GitLab