+def clean_accepted_autobuild():
+ global now_date;
+
+ if not Cnf.FindB("Dinstall::SpecialAcceptedAutoBuild") or Options["No-Action"]:
+ return;
+
+ print "Cleaning out accepted autobuild symlinks..."
+
+ our_delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::AcceptedAutoBuildStayOfExecution"])));
+ count = 0;
+
+ q = projectB.query("SELECT filename FROM unstable_accepted WHERE last_used <= '%s'" % (our_delete_date));
+ for i in q.getresult():
+ filename = i[0];
+ if not os.path.exists(filename):
+ utils.fubar("%s (from unstable_accepted) doesn't exist." % (filename));
+ if not os.path.islink(filename):
+ utils.fubar("%s (from unstable_accepted) should be a symlink but isn't." % (filename));
+ os.unlink(filename);
+ count = count + 1;
+ projectB.query("DELETE FROM unstable_accepted WHERE last_used <= '%s'" % (our_delete_date));
+
+ if count > 0:
+ sys.stderr.write("Cleaned %d accepted-autobuild symlinks.\n" % (count));
+
+################################################################################
+