[Mailman-Users] Re: Quick question about your newlist patch
Gary Algier
gaa at ulticom.com
Sat Jun 17 02:35:27 CEST 2000
Derek Simkowiak wrote:
>
> -> > These patches will make the "Hit enter" `text go to stderr and they will
> -> > omit the "Entry for...". If you want to "see" the output and cut and
> -> > paste with a mouse, use:
> -> > newlist listname user at domain.com somepasswd
> -> > If you don't have or want a mouse, use:
> -> > newlist listname user at domain.com somepasswd >>/etc/aliases
>
> Gary,
> Just to confirm: your patch still allows for interactive input to
> the newlist script, right?
>
> What did you mean by omitting the "Entry for..."? I think the
> newlist script should keep its informational messages, but just print them
> to stderr (or stdout, if the useful stuff goes to stderr--whichever way
> works).
>
> --Derek
Unfortunately, all I really know about Python is how to find the book on
my shelf so I did not want to dig too deeply into the code. Too many
languages, too little time.
In general, in the Unix world, user prompts should go to stderr
(or /dev/tty) so that "real" output can be redirected. Sometime
try the command:
echo g/re/p | ed -x filename >output
and you will see the prompt, the output will get the real output.
[This does a grep of an "encrypted" file]
Well, I gave it a try. I could not find where to fix raw_input() and
getpass() is in the Mailman/pythonlib directory. I did not want to
break anything else by "fixing" getpass, so I did a kludge in newlist.
I made these function calls output nothing, while doing the
sys.stderr.write() just before. I also fixed the usage() function.
<rant>
I hate programs that write error messages and usage messages into
my files.
</rant>
Attached is the new (combined) patch.
[Please excuse the attachment as I can't figure out how to make my
email client (Netscape) insert a file inline. If I cut and paste
I will mess up the spacing.]
--
Gary Algier, WB2FWZ gary.algier at ulticom.com +1 856 787 2758
Ulticom Inc., 1020 Briggs Rd, Mt. Laurel, NJ 08054 Fax:+1 856 866 2033
This space intentionally left blank by the censors.
-------------- next part --------------
--- bin/newlist.old Fri Jun 16 14:10:21 2000
+++ bin/newlist Fri Jun 16 20:10:03 2000
@@ -46,7 +46,6 @@
ALIASTEMPLATE = '''
-Entry for aliases file:
## %(listname)s mailing list
## created: %(date)s %(user)s
@@ -70,9 +69,11 @@
def usage(code, msg=''):
- print __doc__
+ sys.stderr.write(__doc__)
+ sys.stderr.write("\n")
if msg:
- print msg
+ sys.stderr.write(msg)
+ sys.stderr.write("\n")
sys.exit(code)
@@ -81,7 +82,8 @@
if len(argv) > 1:
listname = argv[1]
else:
- listname = raw_input("Enter the name of the list: ")
+ sys.stderr.write("Enter the name of the list: ")
+ listname = raw_input("")
listname = string.lower(listname)
if '@' in listname:
@@ -93,12 +95,13 @@
if len(argv) > 2:
owner_mail = argv[2]
else:
- owner_mail = raw_input(
- "Enter the email of the person running the list: ")
+ sys.stderr.write("Enter the email of the person running the list: ")
+ owner_mail = raw_input("")
if len(argv) > 3:
list_pw = argv[3]
else:
- list_pw = getpass.getpass("Initial %s password: " % listname)
+ sys.stderr.write("Initial %s password: " % listname)
+ list_pw = getpass.getpass("")
mlist = MailList.MailList()
try:
@@ -116,6 +119,7 @@
usage(1, 'Bad owner email address: ' + owner_mail)
+ sys.stderr.write("Entry for aliases file: \n\n")
print ALIASTEMPLATE % {
'listname': listname,
'list' : "%-24s" % (listname + ":"),
@@ -128,7 +132,7 @@
}
if len(argv) < 5:
- print ("Hit enter to continue with %s owner notification..."
+ sys.stderr.write ("Hit enter to continue with %s owner notification..."
% listname),
sys.stdin.readline()
# send the notice to the list owner
More information about the Mailman-Users
mailing list