Don't use this version, its utterly broken.  Clearly use upstream edition :)

Dan


On Thu, Oct 21, 2004 at 06:29:37PM -0400, Barak Bejerano wrote:
> Here is a non recursive version I posted here a while ago:
> #!/usr/bin/python
> 
> # Copyright (C) 2004 Dan Weber <dan at mirrorlynx dot com>
> #
> # This program is free software; you can redistribute it and/or
> # modify it under the terms of the GNU General Public License
> # as published by the Free Software Foundation; either
> # version 2 of the License, or (at your option) any later
> # version.
> #
> # This program is distributed in the hope that it will be useful,
> # but WITHOUT ANY WARRANTY; without even the implied warranty of
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> # GNU General Public License for more details.
> #
> # You should have received a copy of the GNU General Public License
> # along with this program; if not, write to the Free Software
> # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> # $Id: mailbox2dbmail,v 1.2 2004/03/19 15:24:08 ilja Exp $
> 
> import os,sys,getopt,email,email.Errors,mailbox
> version = "%s 1.2" %(sys.argv[0],)
> 
> def main():
>    try:
>        user=mbox=type=''
>        msgnumber=1
>        box = "Inbox"
>        path = "/usr/local/sbin/dbmail-smtp"
>        opts, args = getopt.getopt(sys.argv[1:], "u:m:b:t:p:hv", 
> ["user=","mail=","box=","path=","type=","help","version"])
>        for o, a in opts:
>            if o in ("-v","--version"):
>                print version
>                sys.exit()
>            elif o in ("-h","--help"):
>                usage()
>                sys.exit()
>            elif o in ("-u","--user"):
>                user = a
>            elif o in ("-m","--mail"):
>                mbox = a
>            elif o in ("-b","--box"):
>                box = a
>            elif o in ("-p","--path"):
>                path = a
>            elif o in ("-t","--type"):
>                type = a
>        if not user:
>            print "No user specified"
>            sys.exit(1)
>        if not mbox:
>            print "No mailbox specified"
>            sys.exit(1)
>        if box=="Inbox":
>            print "Using default Inbox"
>        if type=="mbox":
>            mbox = 
> mailbox.PortableUnixMailbox(open(mbox,'r'),email.message_from_file)
>        elif type=="maildir":
>            mbox = mailbox.Maildir(mbox,email.message_from_file)
>        elif type=="mhdir":
>            mbox = mailbox.MHMailbox(mbox,email.message_from_file)
>        elif not type:
>            print "No mailbox type specified"
>            sys.exit(1)
>        convert(user,mbox,box,path)
>    except getopt.GetoptError:
>        usage()
>        print "Error Parsing Options"
>        sys.exit(1)
> 
> def usage():
>    print version
>    print "'%s' -u|--user <user> -t|--type <mbox, maildir, and mhdir> 
> --mail|-m <location of mailbox> -b|--box <Inbox,Inbox.Sent etc> -p <path
> to dbmail-smtp>" %(sys.argv[0],)
> 
> def convert(user,mbox,box,path):
> #    def msgmeter(msgnumber):
>        msgnumber =  1
> #        return convert(user,mbox,box,path,msgnumber)
> 
>        mailmsg = mbox.next()
>        while mailmsg:
>         try:
>           msgnumber = msgnumber + 1
>           command = "'%s' -m '%s' -u '%s'" %(path,box,user)
>           dbmail = os.popen(command,'w')
>           dbmail.writelines(mailmsg.as_string())
>           dbmail.close()
>           del mailmsg
>           print "Processed Message '%s'" %(msgnumber,)
>           mailmsg = mbox.next()
> 
>         except IOError:
>              print "Either box or user is invalid"
>              sys.exit(1)
> 
>         except email.Errors.MessageParseError:
>              print "Error Parsing Mail"
>              sys.exit(1)
> 
> #        return msgmeter(msgnumber)
> 
> #        if not mailmsg:
>        print "All Done!"
>        sys.exit()
> 
> 
> if __name__ == "__main__":
>    main()
> 
> 
> Dan Weber wrote:
> 
> >http://mirrorlynx.com/~dan/mailbox2dbmail-2.0.tar.bz2
> >
> >Updated mailbox2dbmail to fix this.
> >
> >On Thu, Oct 21, 2004 at 06:10:14PM -0400, Dan Weber wrote:
> > 
> >
> >>I'll just fix the script to use a while loop.  I guess it was a defect 
> >>when
> >>I created it.  This should be no problem at all, I'll mail it to the list
> >>when I am done.
> >>
> >>Dan
> >>
> >>On Fri, Oct 22, 2004 at 01:51:19AM +0400, Mikhail Ramendik wrote:
> >>   
> >>
> >>>Dan Stilts wrote:
> >>>
> >>>     
> >>>
> >>>>I had the same error as you ("recursion depth exceeded") so I added 
> >>>>this to the mailbox2dbmail script:
> >>>>
> >>>>sys.setrecursionlimit(6000)
> >>>>       
> >>>>
> >>>Won't help because some of my mailboxes have over 100,000 messages. But
> >>>never mind; I'll just change the script to be non-recursive.
> >>>
> >>>Yours, Mikhail Ramendik
> >>>
> >>>
> >>>
> >>>_______________________________________________
> >>>Dbmail mailing list
> >>>Dbmail@dbmail.org
> >>>https://mailman.fastxs.nl/mailman/listinfo/dbmail
> >>>     
> >>>
> >
> >
> >
> > 
> >
> >>_______________________________________________
> >>Dbmail mailing list
> >>Dbmail@dbmail.org
> >>https://mailman.fastxs.nl/mailman/listinfo/dbmail
> >>   
> >>
> >
> > 
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >Dbmail mailing list
> >Dbmail@dbmail.org
> >https://mailman.fastxs.nl/mailman/listinfo/dbmail
> > 
> >
> 
> _______________________________________________
> Dbmail mailing list
> Dbmail@dbmail.org
> https://mailman.fastxs.nl/mailman/listinfo/dbmail

Attachment: signature.asc
Description: Digital signature

Reply via email to