Page 1 of 2

[RESOLVED] Package error following WAPT 2.0 update

Published: May 6, 2021 - 5:00 PM
by Alann
Good morning,

I developed a package for post-installation configuration of Windows on my network, initially on WAPT 1.8.
The idea is to configure a newly installed workstation by finding its name from its IP address using a reverse DNS lookup.
For that, I use the dnspython module.

Since upgrading to WAPT 2.0, the installation returns an error: AttributeError: 'GenericRdata' object has no attribute 'target'

This error refers to a piece of code:

Code: Select all

def findmachinename(ip):
    pass
    no = dns.reversename.from_address(ip)
    answers = dns.resolver.query(no, 'PTR')
    for rdata in answers:
        nom = rdata
    nommachine = nom.target[0].decode("utf-8")
    return nommachine
The curious thing is that this code works perfectly when run locally on PyScripter, but it fails when deployed to workstations.

Any ideas?

Re: Package error following WAPT 2.0 update

Published: May 7, 2021 - 09:22
by Gaetan
Hi Alann,
is the dnspython package imported at the beginning of your code?
If that doesn't work, perhaps try packaging it with the other package?

Re: Package error following WAPT 2.0 update

Published: May 7, 2021 - 09:26
by Alann
At the beginning of the code I have a

Code: Select all

import dns.resolver
import dns.reversename
How do I package it with the package?

Re: Package error following WAPT 2.0 update

Published: May 7, 2021 - 10:42 AM
by Gaetan
Is it possible to get the error output directly?

Re: Package error following WAPT 2.0 update

Published: May 7, 2021 - 10:50 AM
by Alann
I restarted the installation on a freshly installed machine:

Code: Select all

Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 3841, in install_wapt
    setup = import_setup(setup_filename)
  File "C:\Program Files (x86)\wapt\waptutils.py", line 1498, in import_setup
    py_mod = imp.load_source(modulename, setupfilename)
  File "imp.py", line 171, in load_source
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\windows\TEMP\wapt48wx8rls\setup.py", line 5, in <module>
ModuleNotFoundError: No module named 'dns'
ModuleNotFoundError: No module named 'dns'
Apparently, I need to integrate the dnspython module into the wapt package. I don't know how to do it...

Re: Package error following WAPT 2.0 update

Published: May 7, 2021 - 3:37 PM
by dcardon
Hi Alann,
the dnspython library shouldn't be very large; it's best to include it in the package. You can download the zip file from https://pypi.org/project/dnspython/#files , then extract the "/dns" directory from it and place it in the root directory of your package next to setup.py.
Regards,
Denis

Re: Package error following WAPT 2.0 update

Published: May 7, 2021 - 3:52 PM
by Alann
Hello Denis, and thank you for your reply.

It works perfectly.

The solution was so simple...

Re: Package error following WAPT 2.0 update

Published: May 8, 2021 - 6:47 PM
by Alann
If I had to nitpick, there would just be one point:

The audit on the machines gives the same error message, even though the installation is OK.

Code: Select all

Audit aborted due to exception: No module named 'dns'

Re: Package error following WAPT 2.0 update

Published: May 19, 2021 - 3:45 PM
by Gaetan
Hello Alann,

is it possible to get the complete package code?

Re: Package error following WAPT 2.0 update

Published: May 20, 2021 - 09:24
by Alann
Problem solved.

It was simply a matter of placing the "dns" folder from the PyDSN module in the package.

Remember to also create a copytree to add it to the clients' WAPT libraries; otherwise, package auditing will return an error.