diff --git a/backend/utils.py b/backend/utils.py index b1d18ffe40fdf35a5382370b5c5bf9a9c74a5b53..cd8ce202950b89b06cd85e714ad283051994818e 100644 --- a/backend/utils.py +++ b/backend/utils.py @@ -109,7 +109,7 @@ class StreamStdoutKeepStderr(object): else: last_line = l elif tag == "E": - self.stderr.write(str(buf)) + self.stderr.write(buf) if last_line is not None: yield last_line diff --git a/dsa/housekeeping.py b/dsa/housekeeping.py index d0ab4179f4bf9094e1ede675e28c3580a816e4fa..800a7b373d3b6262dcc66eb739bfcef2a19ac7a8 100644 --- a/dsa/housekeeping.py +++ b/dsa/housekeeping.py @@ -14,11 +14,6 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - - - - - import django_housekeeping as hk from django.db import transaction from backend.housekeeping import MakeLink, Housekeeper diff --git a/dsa/models.py b/dsa/models.py index c688b8310c76e263ac38c2c1621171ac861f64ff..d5793b5fb0bf5c98d33c4e11efb727ffa910a523 100644 --- a/dsa/models.py +++ b/dsa/models.py @@ -1,13 +1,9 @@ """ Code used to access Debian's LDAP """ - from django.db import models from django.conf import settings -try: - import ldap -except ImportError: - import ldap3 as ldap +import ldap3 LDAP_SERVER = getattr(settings, "LDAP_SERVER", "ldap://db.debian.org") @@ -17,13 +13,13 @@ class Entry(object): self.attrs = None self.uid = None - def init(self, dn, attrs): + def init(self, entry): """ Init entry to point at these attributes """ - self.dn = dn - self.attrs = attrs - self.uid = attrs["uid"][0] + self.dn = entry.entry_get_dn() + self.attrs = entry + self.uid = entry["uid"][0] def single(self, name): """ @@ -45,11 +41,10 @@ class Entry(object): return "guest" in self.attrs["supplementaryGid"] def list_people(): - search_base = "dc=debian,dc=org" - l = ldap.initialize(LDAP_SERVER) - l.simple_bind_s("","") + conn = ldap3.Connection(LDAP_SERVER, auto_bind=True) + conn.search("dc=debian,dc=org", "(objectclass=inetOrgPerson)", ldap3.SUBTREE, attributes=ldap3.ALL_ATTRIBUTES) # Create the object only once entry = Entry() - for dn, attrs in l.search_s(search_base, ldap.SCOPE_SUBTREE, "objectclass=inetOrgPerson"): - entry.init(dn, attrs) + for e in conn.entries: + entry.init(e) yield entry diff --git a/keyring/git.py b/keyring/git.py index badcaa109828eabe3b4934b003e361b97d84da32..0fd8c8f86022a6202993682dd1c2dbb69084d56c 100644 --- a/keyring/git.py +++ b/keyring/git.py @@ -71,8 +71,8 @@ class LogEntry(object): if self.re_update_changelog.match(subject): return None if self.re_import_changes.match(subject): return None if body.startswith("Action:"): - operation = email.message_from_string(body.encode("utf-8")) - return dict(list(operation.items())) + operation = email.message_from_string(body) + return dict(operation.items()) else: for match in self.re_summaries: mo = match["re"].match(subject) diff --git a/keyring/git_ops.py b/keyring/git_ops.py index a08516b17a7ed01b5b5bde486ca17d5bf5e02e10..6b92b2d7d873690e88116ea67fda6c8868871bd4 100644 --- a/keyring/git_ops.py +++ b/keyring/git_ops.py @@ -185,7 +185,7 @@ class Add(RoleOperation): This is better than nothing, but not a lot better than that. """ # See http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ - fn = subject.decode('utf8').split() + fn = subject.split() if len(fn) == 1: return fn[0], "", "" elif len(fn) == 2: