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):
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
......
......@@ -14,11 +14,6 @@
#
# 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/>.
import django_housekeeping as hk
from django.db import transaction
from backend.housekeeping import MakeLink, Housekeeper
......
"""
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
......@@ -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)
......
......@@ -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:
......
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