Page 1 of 1
Re: Using the pyad module
Published: January 26, 2018 - 4:43 PM
by dcardon
Good morning,
admin-style wrote: ↑January 26, 2018 - 11:04 AM
Hello everyone,
I manage three fairly large IT infrastructures and I recently adopted WAPT.
I'm quite happy with it and thank the people working on this project as well as the WAPT community.
I have a package that requires the use of the pyad module (a module that allows querying and manipulating Active Directory objects) in addition to installing the FusionInventory software.
I wanted to know how to use this module?
- I saw in a post that it was possible to use modules that can be copied into the WAPT package, but there's no documentation or example.
Could you please specify which version you used (see Alexandre's post)?
viewtopic.php?f=9&t=886). THANKS.
WAPT 1.3: you should be able to include the library by putting it in the root of the package.
WAPT 1.5: the library is included natively
Denis
Re: Using the pyad module
Published: January 29, 2018 - 3:29 PM
by admin-style
Hello, regarding server information and other details, here is the data:
WAPT Server version: 1.3.13.0
WAPT Agent version: 1.3.13.0
WAPT Setup version: 1.3.13.0
WAPT Deploy version: 1.3.13.0
Server is running Linux
, and the machine for the packages is running Windows 7.
Re: Using the pyad module
Published: January 30, 2018 - 2:45 PM
by admin-style
Hello,
when I place the library in the root directory of the WAPT package and run the installer, I get the following error:
FATAL ERROR: ImportError: No module named builtins
Traceback (most recent call last):
File "C:\wapt\wapt-get.py", line 1109, in
main()
File "C:\wapt\wapt-get.py", line 373, in main
res = mywapt.install_wapt(fn,params_dict = params_dict)
File "C:\wapt\common.py", line 3630, in install_wapt
raise e
ImportError: No module named builtins
Re: Using the pyad module
Published: January 31, 2018 - 4:29 PM
by admin-style
Hello,
is there a tutorial explaining how to use the Python module in WAPT packages?
Re: Using the pyad module
Published: February 2, 2018 - 9:47 AM
by admin-style
Hello,
has anyone ever needed to use a module other than those offered by Wapt?
If so, could you show me?
Re: Using the pyad module
Published: February 2, 2018 - 6:32 PM
by agauvrit
Good morning,
- WAPT 1.3: As explained above, by importing the library to the root of your package or into the site-package folder you will be able to use the pyad library during installation (https://pypi.python.org/pypi/pyad)
- WAPT 1.5: The library is included in the WAPT installation and is therefore directly usable
Example of functional code:
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
import pyad.adquery
def install():
print('installing tis-adtest')
q = pyad.adquery.ADQuery()
q.execute_query(
attributes = ["distinguishedName", "description"],
where_clause = "objectClass = '*'",
base_dn = "OU=computers, DC=domain, DC=lan"
)
for row in q.get_results():
print row["distinguishedName"]
Sincerely,
Alexander
Re: Using the pyad module
Published: February 7, 2018 - 11:13 AM
by admin-style
Good morning,
By following the example, I was able to install the package on the machine I use to create packages
Here is my code:
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
from pyad import *
uninstallkey = []
def install():
print('installation fusioninventory-agent')
#Initialisations diverses
ServerFusion = "http://adresse serveur fusion"
idLycee=138
#Recup nom ordinateur et chemin LDAP
ComputerName = get_computername()
ComputerLDAP = pyad.adsearch.by_cn(ComputerName)
#Transformation pour extraction de l'OU
ComputerTab = ComputerLDAP.split(",")
ComputerExtract = ComputerTab[1].split("=")
ComputerOU = ComputerExtract[1]
tag = "%s;%s" % (idLycee,ComputerOU)
print tag
#Lancement de la commande install silencieuse
if iswin64() :
run(r'"fusioninventory-agent_windows-x64_2.3.21.exe" /acceptlicense /runnow /tag="%s" /server="%s" /S' % (tag, ServerFusion))
else:
run(r'"fusioninventory-agent_windows-x64_2.3.21.exe" /acceptlicense /runnow /tag="%s" /server="%s" /S' % (tag, ServerFusion))
However, if I deploy it on a client machine, I get the error
ImportError: No module named builtins
Client workstation log:
Code: Select all
2018-02-07 11:16:45,677 CRITICAL Error importing c:\windows\temp\waptbsr9b4\setup.py :
Traceback (most recent call last):
File "c:\wapt\common.py", line 795, in import_setup
py_mod = imp.load_source(modulename, setupfilename)
File "c:\windows\temp\waptbsr9b4\setup.py", line 3, in <module>
from pyad import *
File "c:\windows\temp\waptbsr9b4\pyad\__init__.py", line 2, in <module>
from .adbase import set_defaults as pyad_setdefaults
File "c:\windows\temp\waptbsr9b4\pyad\adbase.py", line 3, in <module>
from builtins import object
ImportError: No module named builtins
2018-02-07 11:16:46,019 CRITICAL Package claret-fusioninventory not installed due to errors : ImportError: No module named builtins
2018-02-07 11:16:46,019 CRITICAL Exception: Error during install of claret-fusioninventory: errors in packages [[u'claret-fusioninventory', PackageEntry('claret-fusioninventory','2.3.21-2')]]
Thank you for the example of the given code