#9705 Couple of improvements to the retire_packagers script
Merged 2 months ago by humaton. Opened 3 months ago by pingou.
pingou/releng orphan_endpoint  into  master

@@ -182,22 +182,25 @@ 

      session = retry_session()

  

      # Orphan the package

-     url = f"{base_url}/api/0/{namespace}/{name}"

+     url = f"{base_url}/_dg/orphan/{namespace}/{name}"

      headers = {"Authorization": f"token {pagure_token}"}

-     data = {"main_admin": "orphan", "retain_access": False}

+     data = {

+         "orphan_reason": "other",

+         "orphan_reason_info": "Orphaned by releng",

+     }

  

-     req = session.patch(url, data=data, headers=headers)

+     req = self.requests_session.post(url, data=data, headers=headers)

      if not req.ok:

          print("**** REQUEST FAILED")

          print("  - Orphan package")

          print(req.url)

          print(data)

+         print(headers)

          print(req.text)

      else:

          print(f"  {username} is no longer the main admin of {namespace}/{name}")

-     session.close()

  

-     unwatch_package(namespace, name, username)

The dist-git specific endpoint does this automatically?

Yes :)

+     session.close()

  

  

  def remove_access(namespace, name, username, usertype):
@@ -337,7 +340,7 @@ 

              while url:

                  req = session.get(url)

                  data = req.json()

-                 for repo in data["repos"]:

+                 for repo in data.get("repos", []):

                      maintainers = set(repo["user"]["name"])

                      for acl in repo["access_users"]:

                          maintainers.update(set(repo["access_users"][acl]))
@@ -345,7 +348,9 @@ 

                          namespace = repo["namespace"]

                          package = repo["name"]

                          packages_per_user[username].add(f"{namespace}/{package}")

-                 url = data["repos_pagination"]["next"]

+                 url = data.get("repos_pagination", {}).get("next")

+                 if not url:

+                     break

  

      for username in sorted(usernames):

          _log.debug("Processing user: %s", username)

no initial comment

The dist-git specific endpoint does this automatically?

rebased onto 1fa29a9

2 months ago

Pull-Request has been merged by humaton

2 months ago
Metadata