Python error

Help
evilsmo
2009-09-04
2013-06-04
  • evilsmo
    evilsmo
    2009-09-04

    I receive this error on Fedora 11 python-2.6-7.fc11

    /usr/lib/ask/askmessage.py:30: DeprecationWarning: the md5 module is deprecated; use hashlib instead
      import md5
    /usr/lib/ask/askmessage.py:34: DeprecationWarning: the mimify module is deprecated; use the email package instead
      import mimify
    Attention:
    /The system could not deliver your message due to a technical problem.
    Information about the problem has been recorded locally for analysis.
    /--- Problem Details ---
    /Traceback (most recent call last):
      File "/usr/bin/askfilter", line 66, in <module>
        rc = ask.filter(sys.stdin)
      File "/usr/lib/ask/askmain.py", line 118, in filter
        self.msg.deliver_mail("Whitelist match [%s]" % self.msg.list_match)
      File "/usr/lib/ask/askmessage.py", line 484, in deliver_mail
        custom_headers = [ "X-ASK-Auth: " + self.generate_auth() ])
      File "/usr/lib/ask/askmail.py", line 370, in deliver_mail_file
        time.sleep(int(rnd.random() * 3) + 1)
    AttributeError: 'float' object has no attribute 'random'

     
  • Tiger!P
    Tiger!P
    2009-11-28

    you can remove the "import md5" from the askconfig.py
    And here is a diff for the askmessage.py:

        -- askmessage.py.orig  2009-11-28 21:30:16.000000000 +0100
        +++ askmessage.py       2009-11-28 21:30:52.000000000 +0100
        @@ -27,11 +27,11 @@
         import sys
         import string
         import rfc822
        -import md5
        +import hashlib
         import re
         import time
         import tempfile
        -import mimify
        +from email.header import decode_header
         import asklog
         import askconfig
         import askmail
        @@ -117,7 +117,7 @@
                        self.fh = open(self.tmpfile, "r+b")
        
                        ## Create a new MD5 object
         -               self.md5sum = md5.new()
        +               self.md5sum = hashlib.md5()
        
                        ## Copy all the data from the passed file object to the new     file
        
        @@ -181,7 +181,8 @@
                                ## Decode sender name and return if found
                                if sender_mail:
                                        if sender_name:
        -                                       sender_name = mimify.mime_decode_header(sender_name)
        +                                       sender_name = decode_header(sender_name)
        +                                       sender_name = sender_name
                                        break
        
                        return(string.rstrip(sender_name), string.rstrip(sender_mail))
        @@ -213,7 +214,8 @@
                        Returns the subject of the message, or '' if none is defined.
                        """
         
        -               return(mimify.mime_decode_header(self.msg.getheader("Subject", "")))
        +               subject = decode_header(self.msg.getheader("Subject", ""))
        +               return(subject)
        
                #-------------------------------------------------------
                def get_date(self):
        @@ -922,7 +924,7 @@
                        in every email generated by ASK in the X-ASK-Auth: email header.
                        """
        
        -               md5sum = md5.new()
        +               md5sum = hashlib.md5()
        
                        ## number of seconds since epoch as a string
                        numsecs = "%d" % int(time.time())
        @@ -980,7 +982,7 @@
                                self.log.write(1, "  validate_auth_md5(): Cannot read authorization tokens. Authentication Failed.")
         
                        ## Check the md5sum (original_time + rc_md5_key)
        -               md5sum = md5.new()
        +               md5sum = hashlib.md5()
                        md5sum.update("%s" % original_time)             ## Seconds and…
                        md5sum.update(self.config.rc_md5_key)   ## md5 key…
        

    And the diff for askremote.py

        -- askremote.py.orig       2009-11-28 21:31:36.000000000 +0100
        +++ askremote.py    2009-11-28 21:31:51.000000000 +0100
        @@ -28,7 +28,7 @@
         import string
         import tempfile
         import time
        -import md5
        +from hashlib import md5
         import re
         import asklog
         import askconfig
        @@ -573,7 +573,7 @@
                    fileHandle = open(fileName, "r")
        
                    ## Create a new MD5 object
        -           md5sum = md5.new()
        +           md5sum = hashlib.md5()
        
                    while 1:
                            buf = fileHandle.readline()
        @@ -668,7 +668,7 @@
                    sendFileHandle = open(filename, "r")
        
                    ## Create a new MD5 object
        -           md5sum = md5.new()
        +           md5sum = hashlib.md5()
        
                    while 1:
                            buf = sendFileHandle.readline()