script: fix mailmanUser indent

This commit is contained in:
Mathieu Maret 2018-11-21 16:13:19 +01:00
parent 8fbcb6eedc
commit 1f83da3b74

View File

@ -6,6 +6,7 @@ MAILING_PREFIX="noel"
ADMIN_MAIL = "mathieu@mathux.org" ADMIN_MAIL = "mathieu@mathux.org"
ADMIN_PWD = "" ADMIN_PWD = ""
def getListUser(listName): def getListUser(listName):
cmd = MAILMAN_HOME+"/list_members "+listName cmd = MAILMAN_HOME+"/list_members "+listName
proc = subprocess.Popen(cmd, proc = subprocess.Popen(cmd,
@ -22,7 +23,6 @@ def getListUser(listName):
return stdout.split('\n') return stdout.split('\n')
def getMailingLists(prefix): def getMailingLists(prefix):
cmd = MAILMAN_HOME+"/list_lists -b" cmd = MAILMAN_HOME+"/list_lists -b"
proc = subprocess.Popen(cmd, proc = subprocess.Popen(cmd,
@ -42,8 +42,10 @@ def getMailingLists (prefix):
lists.append(line) lists.append(line)
return lists return lists
def createList(name): def createList(name):
cmd = MAILMAN_HOME+"/newlist -a -l fr %s %s %s"%(name,ADMIN_MAIL,ADMIN_PWD) cmd = MAILMAN_HOME + \
"/newlist -a -l fr %s %s %s" % (name, ADMIN_MAIL, ADMIN_PWD)
proc = subprocess.Popen(cmd, proc = subprocess.Popen(cmd,
shell=True, shell=True,
stdin=sys.stdin, stdin=sys.stdin,
@ -56,6 +58,7 @@ def createList(name):
print "error when creating mailing lists : %s" % stderr print "error when creating mailing lists : %s" % stderr
sys.exit(1) sys.exit(1)
def listContainsUser(user, listName): def listContainsUser(user, listName):
return user in getListUser(listName) return user in getListUser(listName)
@ -81,7 +84,7 @@ def addUserToList(userEmail, listName):
def delUserFromList(userEmail, listName): def delUserFromList(userEmail, listName):
if not listContainsUser(userEmail, listName): if not listContainsUser(userEmail, listName):
return return
print "Remove %s to list %s"%(userEmail, listName) print "Remove %s from list %s" % (userEmail, listName)
cmd = MAILMAN_HOME+"/remove_members "+listName+" "+userEmail cmd = MAILMAN_HOME+"/remove_members "+listName+" "+userEmail
proc = subprocess.Popen(cmd, proc = subprocess.Popen(cmd,
shell=True, shell=True,
@ -124,4 +127,3 @@ for listName in allButUserList:
if len(sys.argv) == 4: if len(sys.argv) == 4:
for listName in existingLists: for listName in existingLists:
delUserFromList(sys.argv[3], listName) delUserFromList(sys.argv[3], listName)