Commit 45d6333b authored by Enrico Zini's avatar Enrico Zini
Browse files

Maintenance runs on my laptop

parent c5a29e9e
...@@ -109,7 +109,7 @@ class StreamStdoutKeepStderr(object): ...@@ -109,7 +109,7 @@ class StreamStdoutKeepStderr(object):
else: else:
last_line = l last_line = l
elif tag == "E": elif tag == "E":
self.stderr.write(str(buf)) self.stderr.write(buf)
if last_line is not None: if last_line is not None:
yield last_line yield last_line
......
...@@ -14,11 +14,6 @@ ...@@ -14,11 +14,6 @@
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import django_housekeeping as hk import django_housekeeping as hk
from django.db import transaction from django.db import transaction
from backend.housekeeping import MakeLink, Housekeeper from backend.housekeeping import MakeLink, Housekeeper
......
""" """
Code used to access Debian's LDAP Code used to access Debian's LDAP
""" """
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings
try: import ldap3
import ldap
except ImportError:
import ldap3 as ldap
LDAP_SERVER = getattr(settings, "LDAP_SERVER", "ldap://db.debian.org") LDAP_SERVER = getattr(settings, "LDAP_SERVER", "ldap://db.debian.org")
...@@ -17,13 +13,13 @@ class Entry(object): ...@@ -17,13 +13,13 @@ class Entry(object):
self.attrs = None self.attrs = None
self.uid = None self.uid = None
def init(self, dn, attrs): def init(self, entry):
""" """
Init entry to point at these attributes Init entry to point at these attributes
""" """
self.dn = dn self.dn = entry.entry_get_dn()
self.attrs = attrs self.attrs = entry
self.uid = attrs["uid"][0] self.uid = entry["uid"][0]
def single(self, name): def single(self, name):
""" """
...@@ -45,11 +41,10 @@ class Entry(object): ...@@ -45,11 +41,10 @@ class Entry(object):
return "guest" in self.attrs["supplementaryGid"] return "guest" in self.attrs["supplementaryGid"]
def list_people(): def list_people():
search_base = "dc=debian,dc=org" conn = ldap3.Connection(LDAP_SERVER, auto_bind=True)
l = ldap.initialize(LDAP_SERVER) conn.search("dc=debian,dc=org", "(objectclass=inetOrgPerson)", ldap3.SUBTREE, attributes=ldap3.ALL_ATTRIBUTES)
l.simple_bind_s("","")
# Create the object only once # Create the object only once
entry = Entry() entry = Entry()
for dn, attrs in l.search_s(search_base, ldap.SCOPE_SUBTREE, "objectclass=inetOrgPerson"): for e in conn.entries:
entry.init(dn, attrs) entry.init(e)
yield entry yield entry
...@@ -71,8 +71,8 @@ class LogEntry(object): ...@@ -71,8 +71,8 @@ class LogEntry(object):
if self.re_update_changelog.match(subject): return None if self.re_update_changelog.match(subject): return None
if self.re_import_changes.match(subject): return None if self.re_import_changes.match(subject): return None
if body.startswith("Action:"): if body.startswith("Action:"):
operation = email.message_from_string(body.encode("utf-8")) operation = email.message_from_string(body)
return dict(list(operation.items())) return dict(operation.items())
else: else:
for match in self.re_summaries: for match in self.re_summaries:
mo = match["re"].match(subject) mo = match["re"].match(subject)
......
...@@ -185,7 +185,7 @@ class Add(RoleOperation): ...@@ -185,7 +185,7 @@ class Add(RoleOperation):
This is better than nothing, but not a lot better than that. 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/ # 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: if len(fn) == 1:
return fn[0], "", "" return fn[0], "", ""
elif len(fn) == 2: elif len(fn) == 2:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment