#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    3
    Rep Power
    0

    Using python modules and getting no where fast


    Greetings all,

    I am having a difficult time with adding Spf to Postfix 2.6.6. I hope to use Python modules but it's only been a few days of transition from knowing absolutely nothing about Python (2.6.6) to this point.

    Please enlighten me...

    I'm attempting to follow the tarball installation of "pyspf 2.0.8". Py modules to use with pyspf include...
    -ipaddr 2.1.9
    -pydns 2.3.6
    -authres 0.602

    Yet I could only test pydns; there was a sub directory "tests" with some handy .py programs (yes!) and results were good. No dice for testing the other supporting modules (continue if you dare...ok).

    Disappointment is what I get from the sub directory "test" of pyspf.
    Code:
    # pwd
    
    /tmp/pyspf-2.0.8/test
    Code:
    # python testspf.py
    
    .WARN: spfonly in rfc4408-tests.yml, 4.4/1: fail preferred to none
    WARN: invalid-domain-long in rfc4408-tests.yml, ['4.3/1', '5/10/3']: permerror preferred to fail
    E.................
    ======================================================================
    ERROR: testRFC (__main__.SPFTestCase)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "testspf.py", line 193, in testRFC
        self.runTest(list(loadYAML('rfc4408-tests.yml').values()))
      File "testspf.py", line 164, in runTest
        res,code,exp = q.check()
      File "/usr/lib/python2.6/site-packages/spf.py", line 612, in check
        rc = self.check1(spf, self.d, 0)
      File "/usr/lib/python2.6/site-packages/spf.py", line 651, in check1
        return self.check0(spf, recursion)
      File "/usr/lib/python2.6/site-packages/spf.py", line 960, in check0
        if self.cidrmatch(self.dns_mx(arg), cidrlength):
      File "/usr/lib/python2.6/site-packages/spf.py", line 1260, in dns_mx
        return [a for mx in mxnames[:max] for a in self.dns_a(mx[1],self.A)]
      File "/usr/lib/python2.6/site-packages/spf.py", line 1276, in dns_a
        return [ipaddress.Bytes(ip) for ip in r]
    AttributeError: 'module' object has no attribute 'Bytes'
    
    ----------------------------------------------------------------------
    Ran 19 tests in 6.647s
    
    FAILED (errors=1)
    Oh, I'm missing a module (or I have a bad one). I don't know if Python wants something from the module it just exit from or the one it wants next.
    Code:
    ...a small fragment from /usr/lib/python2.6/site-packages/spf.py
        def dns_a(self, domainname, A='A'):
            """Get a list of IP addresses for a domainname.
            """
            if not domainname: return []
            if self.strict > 1:
                alist = self.dns(domainname, A)
                if len(alist) == 0:
                    raise AmbiguityWarning(
                            'No %s records found for'%A, domainname)
                else:
                    return alist
            r = self.dns(domainname, A)
            if A == 'AAAA' and bytes is str:
              # work around pydns inconsistency plus python2 bytes/str ambiguity
              return [ipaddress.Bytes(ip) for ip in r]
            return r
    Thanks for taking the time,
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,893
    Rep Power
    481
    Happy Thanksgiving. I do not know the problem nor it's answer.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    3
    Rep Power
    0
    Hey, thanks for the pointers!

    I'm really looking for some help with the syntax of that block, in particular the return statement. I'm guessing if the ip address is an ipv6 address (AAAA) a different result is returned using ipaddress.Bytes().

    Instead of falling through to this last IF test could it be bypassed? This is the line (section) of the module that is producing an error.

    Are you Iggy Pop? You look like him, do you get that a lot?
    Last edited by Patgnd; November 28th, 2013 at 08:47 PM. Reason: Sorry, I'm Canadian! Turkey Day in October and not about pilgrims!
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,893
    Rep Power
    481
    Your are the first person to recognize my likeness with iggy pop.

    The module hasn't got a Bytes method. There's nothing wrong with the syntax. I'm using the Ubuntu distribution therefore spf runs on my computer. I poked around the internet a little without finding pyspf. Today I concentrated more on food and less on your concern.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    3
    Rep Power
    0
    Ah yes Ubuntu. Well I'm using Rhel.

    I'm wasting time with this puruit in Python. There is no shortage of Perl and Cpan modules but this is the path I was tring to avoid; discover some other programming elements.

    Thanks for being there, b49P!


IMN logo majestic logo threadwatch logo seochat tools logo