FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Infrastructure

 
 
LinkBack Thread Tools
 
Old 01-11-2010, 12:38 AM
Todd Zullinger
 
Default mailman: Parse arguments to fedora-mailing-list-setup

This allows the script to be used non-interactively.
---
configs/mailman/fedora-mailing-list-setup | 30 +++++++++++++++++++++-------
1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/configs/mailman/fedora-mailing-list-setup b/configs/mailman/fedora-mailing-list-setup
index 471e77d..6e9385b 100755
--- a/configs/mailman/fedora-mailing-list-setup
+++ b/configs/mailman/fedora-mailing-list-setup
@@ -22,8 +22,7 @@ import sys
import pwd
import grp
import os
-import getpass
-import getopt
+import optparse
import sha

try:
@@ -139,9 +138,13 @@ def switch_user():
os.setgid(mailman_gid)
os.setuid(mailman_uid)

-def ask_questions(listType):
+def ask_questions(listType, *args):
+ args = list(args)
if listType == "hosted":
- project = raw_input('Project name: ').strip().lower()
+ if len(args) > 0:
+ project = args.pop(0)
+ else:
+ project = raw_input('Project name: ').strip().lower()
found = False
for vcs in ['cvs', 'git', 'hg', 'mtn', 'svn']:
try:
@@ -153,8 +156,11 @@ def ask_questions(listType):

if not found:
usage(1, 'Can't find a project named "%s"!' % project)
-
- listname = raw_input('List name: ').strip().lower()
+
+ if len(args) > 0:
+ listname = args[0]
+ else:
+ listname = raw_input('List name: ').strip().lower()

if listType == "hosted":
if listname != project and not listname.startswith(project + '-'):
@@ -166,7 +172,10 @@ def ask_questions(listType):
if Utils.list_exists(listname):
usage(1, 'List already exists: "%s"!' % listname)

- admin = raw_input('Admin username: ').strip().lower()
+ if len(args) > 1:
+ admin = args[1]
+ else:
+ admin = raw_input('Admin username: ').strip().lower()

try:
pw = pwd.getpwnam(admin)
@@ -195,10 +204,15 @@ def main():
hostname = os.uname()[1]
if hostname.startswith("hosted"):
listType = "hosted"
+ usage = '%prog [project[listname[listadmin]]]'
else:
listType = "other"
+ usage = '%prog[listname[listadmin]]'
+
+ parser = optparse.OptionParser(usage=usage)
+ opts, args = parser.parse_args()

- listname, admin = ask_questions(listType)
+ listname, admin = ask_questions(listType, *args)
switch_user()
create_list(listname, '%s@fedoraproject.org' % admin)

--
1.6.6

_______________________________________________
infrastructure mailing list
infrastructure@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/infrastructure
 

Thread Tools




All times are GMT. The time now is 03:29 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org