+ return last
+
+def getLastKeyringChangeTime():
+ krmod = 0
+ for k in Keyrings:
+ mt = os.path.getmtime(k)
+ if mt > krmod:
+ krmod = mt
+
+ return int(krmod)
+
+def getLastBuildTime(gdir):
+ cache_last_ldap_mod = 0
+ cache_last_unix_mod = 0
+ cache_last_run = 0
+
+ try:
+ fd = open(os.path.join(gdir, "last_update.trace"), "r")
+ cache_last_mod=fd.read().split()
+ try:
+ cache_last_ldap_mod = cache_last_mod[0]
+ cache_last_unix_mod = int(cache_last_mod[1])
+ cache_last_run = int(cache_last_mod[2])
+ except IndexError, ValueError:
+ pass
+ fd.close()
+ except IOError, e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise e
+
+ return (cache_last_ldap_mod, cache_last_unix_mod, cache_last_run)
+
+def ud_generate():
+ parser = optparse.OptionParser()
+ parser.add_option("-g", "--generatedir", dest="generatedir", metavar="DIR",
+ help="Output directory.")
+ parser.add_option("-f", "--force", dest="force", action="store_true",
+ help="Force generation, even if no update to LDAP has happened.")
+
+ (options, args) = parser.parse_args()
+ if len(args) > 0:
+ parser.print_help()
+ sys.exit(1)
+
+ if options.generatedir is not None:
+ generate_dir = os.environ['UD_GENERATEDIR']
+ elif 'UD_GENERATEDIR' in os.environ:
+ generate_dir = os.environ['UD_GENERATEDIR']
+ else:
+ generate_dir = GenerateDir
+
+
+ lockf = os.path.join(generate_dir, 'ud-generate.lock')
+ lock = get_lock( lockf )