Development #29418
Fonctionner avec python3
0%
Description
Parce qu'on en aura besoin pour la compatibilité d'A2 avec python3.
Fichiers
Révisions associées
Historique
Mis à jour par Paul Marillonnet il y a plus de 5 ans
- Statut changé de Nouveau à Information nécessaire
Étrange, à l'exécution des tests (même en python2) l'instanciation d'un ldaptools.slapd.Slapd
se fait en allant chercher la clé privée ssl-cert-snakeoil.key
dans le repértoire de tests ldaptools (à savoir, dans mon cas, ~/src/ldaptools/tests/
, et non pas dans /etc/ssl/
).
Est-ce que je suis censé gérer une nouvelle paire de clés réservée à l'exécution des tests unitaires ?
Mis à jour par Paul Marillonnet il y a plus de 5 ans
- Statut changé de Information nécessaire à En cours
Le passage en python3 cause des erreurs de parsing LDIF1, je suis sur le coup.
1 Par exemple :
========================================================================================== FAILURES =========================================================================================== ____________________________________________________________________________________ test_synchronize_ldif ____________________________________________________________________________________ slapd = <ldaptools.slapd.Slapd object at 0x7fd2b31ed390> def test_synchronize_ldif(slapd): pivot_attributes = ( ('organization', 'o'), ('inetOrgPerson', 'uid'), ('organizationalUnit', 'ou'), ) attributes = ['o', 'objectClass', 'uid', 'sn', 'givenName', 'mail', 'dc', 'cn'] conn = slapd.get_connection_admin() def syn_ldif(ldif): parser = ListLDIFParser(StringIO(ldif)) parser.parse() synchronize = Synchronize(parser, 'o=orga', conn, 'o=orga', pivot_attributes=pivot_attributes, attributes=attributes) synchronize.run() return synchronize ldif = '''dn: o=orga o: orga dc: coucou objectClass: organization objectClass: dcObject dn: uid=admin,o=orga objectClass: inetOrgPerson cn: John Doe uid: admin sn: John givenName: Doe mail: john.doe@entrouvert.com ''' > synchronize = syn_ldif(ldif) tests/test_synchronize.py:47: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_synchronize.py:28: in syn_ldif synchronize.run() src/ldaptools/synchronize.py:285: in run self.build_actions() src/ldaptools/synchronize.py:244: in build_actions self.build_actions_for_entries(batch) src/ldaptools/synchronize.py:187: in build_actions_for_entries objectclass, attr, value = self.get_pivot_attribute(dn, entry) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <ldaptools.synchronize.Synchronize object at 0x7fd2b31e35f8>, dn = 'o=orga', entry = caselessDict({'o': [b'orga'], 'dc': [b'coucou'], 'objectclass': <map object at 0x7fd2b32016a0>}) def get_pivot_attribute(self, dn, entry): '''Find a pivot attribute value for an LDAP entry''' for objc, attr in self.pivot_attributes: entry['objectclass'] = map(istr, entry['objectclass']) if objc in entry['objectclass']: try: value = entry[attr] except KeyError: raise Exception('entry %s missing pivot attribute %s: %s' % (dn, attr, entry)) break else: raise Exception('entry %s has unknown objectclasses %s' % (dn, > [objclass for objclass in entry['objectclass']])) E Exception: entry o=orga has unknown objectclasses [] src/ldaptools/synchronize.py:156: Exception ____________________________________________________________________________________ test_synchronize_ldap ____________________________________________________________________________________ slapd = <ldaptools.slapd.Slapd object at 0x7fd2b3239080> def test_synchronize_ldap(slapd): pivot_attributes = ( ('organization', 'o'), ('inetOrgPerson', 'uid'), ('organizationalUnit', 'ou'), ) attributes = ['o', 'objectClass', 'uid', 'sn', 'givenName', 'mail', 'dc', 'cn'] conn = slapd.get_connection_admin() slapd.add_db('dc=orga2') ldif = '''dn: dc=orga2 o: orga dc: orga2 objectClass: organization objectClass: dcObject dn: uid=admin,dc=orga2 objectClass: inetOrgPerson cn: John Doe uid: admin sn: John givenName: Doe mail: john.doe@entrouvert.com ''' slapd.add_ldif(ldif) source = LDAPSource(conn, base_dn='dc=orga2', attributes=attributes) synchronize = Synchronize(source, 'dc=orga2', conn, 'o=orga', pivot_attributes=pivot_attributes, attributes=attributes) > synchronize.run() tests/test_synchronize.py:119: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ src/ldaptools/synchronize.py:285: in run self.build_actions() src/ldaptools/synchronize.py:244: in build_actions self.build_actions_for_entries(batch) src/ldaptools/synchronize.py:187: in build_actions_for_entries objectclass, attr, value = self.get_pivot_attribute(dn, entry) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <ldaptools.synchronize.Synchronize object at 0x7fd2b32398d0>, dn = 'dc=orga2', entry = caselessDict({'o': [b'orga'], 'dc': [b'orga2'], 'objectclass': <map object at 0x7fd2b3239d30>}) def get_pivot_attribute(self, dn, entry): '''Find a pivot attribute value for an LDAP entry''' for objc, attr in self.pivot_attributes: entry['objectclass'] = map(istr, entry['objectclass']) if objc in entry['objectclass']: try: value = entry[attr] except KeyError: raise Exception('entry %s missing pivot attribute %s: %s' % (dn, attr, entry)) break else: raise Exception('entry %s has unknown objectclasses %s' % (dn, > [objclass for objclass in entry['objectclass']])) E Exception: entry dc=orga2 has unknown objectclasses [] src/ldaptools/synchronize.py:156: Exception
Mis à jour par Paul Marillonnet il y a plus de 5 ans
- Fichier 0001-add-python3-compatibility-29418.patch 0001-add-python3-compatibility-29418.patch ajouté
- Statut changé de En cours à Solution proposée
- Patch proposed changé de Non à Oui
Mis à jour par Benjamin Dauvergne il y a plus de 5 ans
- Fichier 0001-wip.patch 0001-wip.patch ajouté
J'avais ça en local.
Mis à jour par Benjamin Dauvergne il y a plus de 5 ans
Mais c'est aussi lié à des changements dans python-ldap > 3 qui se met à supporter unicode en python2 (on doit supporte python-ldap 3 même en python2 en fait, il n'y aura plus que ça bientôt).
Mis à jour par Paul Marillonnet il y a plus de 5 ans
- Statut changé de Solution proposée à En cours
Ok cool, merci pour l'info, je vais prendre ça en compte et proposer un nouveau patch, avec tout en python-ldap 3.
Erreur dans mon patch, il y a aussi un
if istr(v) in self.objectclasses
qui a disparu d'une listcomp dans synchronize.py, je corrige aussi.
Mis à jour par Paul Marillonnet il y a plus de 5 ans
- Fichier 0001-add-python3-compatibility-29418.patch 0001-add-python3-compatibility-29418.patch ajouté
- Statut changé de En cours à Solution proposée
Impossible de faire fonctionner
- python-ldap<3 + ldappre3: python-ldap<3 + !ldappre3: python-ldap>=3
alors que pourtant c'est documenté1.
Je me mange une erreur de parsing du fichier
tox.ini
. Pas compris, j'ai dû procéder autrement, rien de bien grave.
Pour le reste c'est ici, avec correction de l'erreur d'étourderie mentionnée dans #29418-6.
1 https://tox.readthedocs.io/en/latest/config.html#complex-factor-conditions
Mis à jour par Benjamin Dauvergne il y a environ 5 ans
- Fichier 0002-tox.ini-remove-call-to-eobuilder.patch 0002-tox.ini-remove-call-to-eobuilder.patch ajouté
- Fichier 0001-add-python3-compatibility-29418.patch 0001-add-python3-compatibility-29418.patch ajouté
Relu, poussable.
Mis à jour par Paul Marillonnet il y a environ 5 ans
# python2 backward compat try: tested_types = basestring except NameError: tested_types = str
Erreur de ma part ici, il suffit d'utiliser six.string_types
Mis à jour par Paul Marillonnet il y a environ 5 ans
- Fichier 0001-add-python3-compatibility-29418.patch 0001-add-python3-compatibility-29418.patch ajouté
Corrigé ici.
Mis à jour par Benjamin Dauvergne il y a environ 5 ans
- Statut changé de Solution proposée à Solution validée
Ack, pousse mon patch eobuilder aussi.
Mis à jour par Paul Marillonnet il y a environ 5 ans
Est-ce que dans ton patch tu m'autorises aussi à changer :
diff --git a/tox.ini b/tox.ini index 735d177..8fd3386 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ [tox] toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/ldaptools/ -envlist = py2-coverage-ldap2,py{2,3}-coverage-ldap3,package +envlist = py2-coverage-ldap2,py{2,3}-coverage-ldap3 [testenv] usedevelop = true
?
Mis à jour par Paul Marillonnet il y a environ 5 ans
- Statut changé de Solution validée à Résolu (à déployer)
commit 9b7c0e441d4888970cdb9e39aec700c0fe07c1c8 Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Tue Feb 26 23:33:09 2019 +0100 tox.ini: remove call to eobuilder commit 7d8c8e9429f253cf2713b14b6f08478369351d31 Author: Paul Marillonnet <pmarillonnet@entrouvert.com> Date: Thu Jan 10 18:33:25 2019 +0100 add python3 compatibility (#29418)
Mis à jour par Benjamin Dauvergne il y a environ 5 ans
- Statut changé de Résolu (à déployer) à Fermé
add python3 compatibility (#29418)