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.