[Tutor] hints on uuencoding?

James Rocks uktechportal at yahoo.co.uk
Wed Mar 28 12:57:40 CEST 2007


OK ... so I got my mail receipt working (thanks Rikard) but one thing I will be downloading is attached TRN files.

I can download a mail and subsequently put it in a text file but then I want as easy a way as possible (which may or may not involve uudecoding, there may well be a way to simply pull the attached file off for all I know) to get that file from either trhe text file or the mail object: 

Here's my code so far: 

def GetVGAPMail(sServer='', sUser='', sPassword=''):
    import getpass, poplib
    from string import split, strip, upper
    from os import system

    _TRUE_ = 1
    _FALSE_ = 0

    vMail = poplib.POP3(sServer)
    vMail.user(sUser)
    vMail.pass_(sPassword)
    iMessages = len(vMail.list()[1])

    aMail = []
    for iLoop in range(iMessages):
        # print "**** Loop", iLoop
        lDel = _TRUE_
        fWrite = open ("temp.txt", 'w')
        for sLine in vMail.retr(iLoop + 1)[1]:
            fWrite.write ("%s\n" % sLine)
            # print sLine
            sLine = strip(sLine)
            if len(sLine) > 1:
                aLine = split(sLine)
                # print aLine
                if aLine[0] == "Subject:" and len(aLine) > 1:
                    sCommand = upper(aLine[0])
                    aParam = aLine[1:]
                
                if

        fWrite.close()

        if sCommand == "TURN":
            # download file
            print "**** TURN ****"
            lDel = _FALSE_
        elif sCommand == "RESEND":
            # resend RST
            print "**** RESEND ****"
        elif sCommand == "MAIL":
            # change mail address
            print "**** MAIL ****"
        elif sCommand == "PASSWORD":
            # change password
            print "**** PASSWORD ****"
        elif sCommand == "STATUS":
            # change mail game status
            print "**** STATUS ****"
        else: 
            # change send help file
            print "**** HELP ****"

        if lDel:
            # rename file to temp name (will ultimately delete file)
            print "**** Rename temp.txt to del.txt ****"
            system("ren temp.txt del%s.txt" % iLoop)
        else:
            # rename file to PLAYER3.TRN (this is the file with an attachmnet)
            print "**** Rename temp.txt to PLAYER3.TRN ****"
            system("ren temp.txt PLAYER3.TRN")

Any ideas?

Kyu




		
___________________________________________________________ 
Win a BlackBerry device from O2 with Yahoo!. Enter now. http://www.yahoo.co.uk/blackberry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070328/e299527e/attachment.htm 


More information about the Tutor mailing list