X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fclean_suites.py;h=7419b83b5496e9b3ecca15e19d71326b8e449be0;hb=51964a1cda58d2292b66bc97f594804ed8190d49;hp=b0711acbcc30a506a2b5bfc8efc2c128a52ecd8a;hpb=7701b2df5bca50d8535d393e9e84ce624af7cc55;p=dak.git diff --git a/dak/clean_suites.py b/dak/clean_suites.py index b0711acb..7419b83b 100755 --- a/dak/clean_suites.py +++ b/dak/clean_suites.py @@ -128,6 +128,7 @@ SELECT s.id, s.file, f.filename (SELECT sa.source FROM src_associations sa) AND s.id NOT IN (SELECT b.source FROM binaries b) + AND s.id NOT IN (SELECT esr.src_id FROM extra_src_references esr) AND f.id NOT IN (SELECT bqf.fileid FROM build_queue_files bqf)""") @@ -171,6 +172,7 @@ SELECT s.id, s.file, f.filename SELECT f.id, f.filename FROM source s, files f, dsc_files df WHERE f.last_used IS NOT NULL AND s.id = df.source AND df.file = f.id AND ((EXISTS (SELECT 1 FROM src_associations sa WHERE sa.source = s.id)) + OR (EXISTS (SELECT 1 FROM extra_src_references esr WHERE esr.src_id = s.id)) OR (EXISTS (SELECT 1 FROM binaries b WHERE b.source = s.id)) OR (EXISTS (SELECT 1 FROM build_queue_files bqf WHERE bqf.fileid = s.file)))""") @@ -244,10 +246,18 @@ def clean(now_date, delete_date, max_delete, session): print "Cleaning out packages..." - cur_date = now_date.strftime("%Y-%m-%d") - dest = os.path.join(cnf["Dir::Morgue"], cnf["Clean-Suites::MorgueSubDir"], cur_date) + morguedir = cnf.get("Dir::Morgue", os.path.join("Dir::Pool", 'morgue')) + morguesubdir = cnf.get("Clean-Suites::MorgueSubDir", 'pool') + + # Build directory as morguedir/morguesubdir/year/month/day + dest = os.path.join(morguedir, + morguesubdir, + str(now_date.year), + '%.2d' % now_date.month, + '%.2d' % now_date.day) + if not Options["No-Action"] and not os.path.exists(dest): - os.mkdir(dest) + os.makedirs(dest) # Delete from source print "Deleting from source table... " @@ -416,7 +426,7 @@ def main(): max_delete = int(cnf["Clean-Suites::Options::Maximum"]) if max_delete < 1: utils.fubar("If given, Maximum must be at least 1") - except ValueError, e: + except ValueError as e: utils.fubar("If given, Maximum must be an integer") else: max_delete = None @@ -429,7 +439,11 @@ def main(): session = DBConn().session() now_date = datetime.now() - delete_date = now_date - timedelta(seconds=int(cnf['Clean-Suites::StayOfExecution'])) + + # Stay of execution; default to 1.5 days + soe = int(cnf.get('Clean-Suites::StayOfExecution', '129600')) + + delete_date = now_date - timedelta(seconds=soe) check_binaries(now_date, delete_date, max_delete, session) clean_binaries(now_date, delete_date, max_delete, session)