* ud-mailgate: Do not try to do an ldap modify with no changes - now show
command to changes@ should work again.
* ud-generate: No longer expand $ in dnsZoneEntry data to a \n\t.
+ * ud-generate: Move code into getLastBuildTime() and getLastLDAPChangeTime()
+ functions.
[ Stephen Gran ]
* Fix deprecation warnings for sha module by using hashlib module instead
* ud-replicate: set correct permissions for web-passwords
* add freecdb to depends
- -- Peter Palfrader <weasel@debian.org> Mon, 12 Mar 2012 11:37:18 +0100
+ -- Peter Palfrader <weasel@debian.org> Mon, 12 Mar 2012 11:45:44 +0100
userdir-ldap (0.3.79) unstable; urgency=low
pass
DoLink(global_dir, OutDir, "last_update.trace")
-l = make_ldap_conn()
-mods = l.search_s('cn=log',
- ldap.SCOPE_ONELEVEL,
- '(&(&(!(reqMod=activity-from*))(!(reqMod=activity-pgp*)))(|(reqType=add)(reqType=delete)(reqType=modify)(reqType=modrdn)))',
- ['reqEnd'])
+def getLastLDAPChangeTime(l):
+ mods = l.search_s('cn=log',
+ ldap.SCOPE_ONELEVEL,
+ '(&(&(!(reqMod=activity-from*))(!(reqMod=activity-pgp*)))(|(reqType=add)(reqType=delete)(reqType=modify)(reqType=modrdn)))',
+ ['reqEnd'])
-last = 0
+ last = 0
-# Sort the list by reqEnd
-sorted_mods = sorted(mods, key=lambda mod: mod[1]['reqEnd'][0].split('.')[0])
-# Take the last element in the array
-last = sorted_mods[-1][1]['reqEnd'][0].split('.')[0]
+ # Sort the list by reqEnd
+ sorted_mods = sorted(mods, key=lambda mod: mod[1]['reqEnd'][0].split('.')[0])
+ # Take the last element in the array
+ last = sorted_mods[-1][1]['reqEnd'][0].split('.')[0]
-# override globaldir for testing
-if 'UD_GENERATEDIR' in os.environ:
- GenerateDir = os.environ['UD_GENERATEDIR']
+ return last
-cache_last_mod = 0
+def getLastBuildTime():
+ cache_last_mod = 0
-try:
- fd = open(os.path.join(GenerateDir, "last_update.trace"), "r")
- cache_last_mod=fd.read().split()
try:
- cache_last_mod = cache_last_mod[0]
- except IndexError:
- pass
- fd.close()
-except IOError, e:
- if e.errno == errno.ENOENT:
- pass
- else:
- raise e
+ fd = open(os.path.join(GenerateDir, "last_update.trace"), "r")
+ cache_last_mod=fd.read().split()
+ try:
+ cache_last_mod = cache_last_mod[0]
+ except IndexError:
+ pass
+ fd.close()
+ except IOError, e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise e
+
+ return cache_last_mod
+
+
+
+l = make_ldap_conn()
+
+# override globaldir for testing
+if 'UD_GENERATEDIR' in os.environ:
+ GenerateDir = os.environ['UD_GENERATEDIR']
-if cache_last_mod >= last:
+ldap_last_mod = getLastLDAPChangeTime(l)
+cache_last_mod = getLastBuildTime()
+if cache_last_mod >= ldap_last_mod:
fd = open(os.path.join(GenerateDir, "last_update.trace"), "w")
- fd.write("%s\n%s\n" % (last, int(time.time())))
+ fd.write("%s\n%s\n" % (ldap_last_mod, int(time.time())))
fd.close()
sys.exit(0)
tracefd = open(os.path.join(GenerateDir, "last_update.trace"), "w")
generate_all(GenerateDir, l)
- tracefd.write("%s\n%s\n" % (last, int(time.time())))
+ tracefd.write("%s\n%s\n" % (ldap_last_mod, int(time.time())))
tracefd.close()
finally: