On Sat, Mar 23, 2019 at 4:31 AM Antonio Terceiro antonio.terceiro@linaro.org wrote:
On Fri, Mar 22, 2019 at 09:24:27PM +0800, Chase Qi wrote:
Hi Antonio,
On Fri, Mar 22, 2019 at 9:18 PM Antonio Terceiro antonio.terceiro@linaro.org wrote:
On Fri, Mar 22, 2019 at 05:14:20PM +0800, Chase Qi wrote:
Hi,
I wrote the script https://github.com/chase-qi/tools/blob/master/squad/create_project.py to create squad project if it doesn't exist. It works fine with public project, but doesn't work well with private project. The reason is it fails to get the new created private project.
For the first time, private project can be created successfully.
(env) cq@tp:~/github/chase-qi/tools/squad$ ./create_project.py -p lkft-gps-private -P False 2019-03-22 17:05:44,699: get_list: INFO: groups get request status code: 200 2019-03-22 17:05:46,745: get_list: INFO: projects get request status code: 200 2019-03-22 17:05:48,797: main: INFO: Data to POST: { "group": "https://staging-qa-reports.linaro.org/api/groups/5/", "slug": "lkft-gps-private",
[...]
When creating the same project again, the following error returned.
(env) cq@tp:~/github/chase-qi/tools/squad$ ./create_project.py -p lkft-gps-private -P False 2019-03-22 17:05:56,582: get_list: INFO: groups get request status code: 200 2019-03-22 17:05:58,628: get_list: INFO: projects get request status code: 200 2019-03-22 17:06:00,674: main: INFO: Data to POST: { "group": "https://staging-qa-reports.linaro.org/api/groups/5/", "slug": "lkft-gps-private",
[...] [...]
2019-03-22 17:06:02,310: creat_project: INFO: Project created: { "non_field_errors": [ "The fields group, slug must make a unique set." ] } (env) cq@tp:~/github/chase-qi/tools/squad$
The script able to check if the project to create already exist by comparing the project name with the existing projects. `However, requests.get(url, headers=headers)` only return public project and old existing private project, it doesn't return the new created private ones.
In this example you are trying to craete two projects with the same name(slug) "lkft-gps-private" under the same project (5). You cannot do that, and that's exactly what the error message you got is saying.
This is trying to simulate when user/ci use the script to create a project that already exist. This block of code https://github.com/chase-qi/tools/blob/master/squad/create_project.py#L101 check if the project exist, if yes, then print existing projects and return. The problem is kft-gps-private doesn't appear in the returned projects. This line https://github.com/chase-qi/tools/blob/master/squad/create_project.py#L132 to create project shouldn't be executed in this case.
Ah! Ok, I understand now. What user are you using to call the API? I
I am using the token genereated from here https://staging-qa-reports.linaro.org/_/settings/api-token/ . The one listed here for chase.qi https://staging-qa-reports.linaro.org/admin/authtoken/token/
Thanks, Chase
think there is a bug in the authorization code that is causing a mismatch between the permissions needed to create a project and the ones needed to be able to see it later if it's private. _______________________________________________ Squad-dev mailing list Squad-dev@lists.linaro.org https://lists.linaro.org/mailman/listinfo/squad-dev