From 45d6333b644620e04e45e08bb45e6f7ee289e31b Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Wed, 2 Aug 2017 17:49:33 -0400 Subject: [PATCH] Maintenance runs on my laptop --- backend/utils.py | 2 +- dsa/housekeeping.py | 5 ----- dsa/models.py | 23 +++++++++-------------- keyring/git.py | 4 ++-- keyring/git_ops.py | 2 +- 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/backend/utils.py b/backend/utils.py index b1d18ffe..cd8ce202 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 d0ab4179..800a7b37 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 c688b831..d5793b5f 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 badcaa10..0fd8c8f8 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 a08516b1..6b92b2d7 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: -- GitLab