#533 2 bug fixes in the fasjson email aliases script
Merged a month ago by kevin. Opened a month ago by scoady.
fedora-infra/ scoady/ansible fix-aliases-script  into  main

@@ -2,6 +2,7 @@ 

  import os

  import sys

  import tempfile

+ import subprocess

  

  from fasjson_client import Client, errors

  
@@ -36,19 +37,16 @@ 

                  for group in groups:

                      groupname = group['groupname']

  

-                     # even though there are no admins of groups anymore

-                     # we should probably leave this here and just

-                     # link to the sponsors list

-                     temp.write(

-                         f'{groupname}-administrators: {groupname}-sponsors \n'

-                     )

- 

                      sponsor_list = ','.join(

                          sponsor['username']

                          for sponsor in client.list_group_sponsors(

                              groupname=groupname).result

                      )

-                     temp.write(f"{groupname}-sponsors: {sponsor_list} \n")

+                     if sponsor_list:

+                         temp.write(

+                             f'{groupname}-administrators: {groupname}-sponsors \n'

+                         )

+                         temp.write(f"{groupname}-sponsors: {sponsor_list} \n")

  

                      member_list = ','.join(

                          member['username']
@@ -56,7 +54,9 @@ 

                              groupname=groupname).result

                      )

  

-                     temp.write(f"{groupname}-members: {member_list} \n")

+                     if member_list:

+                         temp.write(f"{groupname}-members: {member_list} \n")

+ 

              rename(temporary_file.name, aliases_file)

          except errors.APIError as e:

              print(f"Something went wrong querying the fasjson API. {e}", file=sys.stderr)
@@ -117,8 +117,12 @@ 

      try:

          if not args:

              gen_all_aliases()

+             # call newaliases script so postfix gets updated

+             subprocess.check_call(['/usr/bin/newaliases'])

          elif len(args) == 2 and args[0] == "update":

              update_user(args[1])

+             # call newaliases script so postfix gets updated

+             subprocess.check_call(['/usr/bin/newaliases'])

          else:

              print(f"Usage: {sys.argv[0]} [update <username>]", file=sys.stderr)

              raise RuntimeError()

Looks good to me. Thanks!

rebased onto b9127762b9788ea16bc1e8e9396cd4abec0b7946

a month ago

This would require a freeze break to push now, but I am in favor of doing so, so +1 Freeze Break from me.

rebased onto 88b6b0e

a month ago

rebased onto 88b6b0e

a month ago

Pull-Request has been merged by kevin

a month ago
Metadata