From 761f14e0dc1d86568910c02fa8f1a8b28e7f0f59 Mon Sep 17 00:00:00 2001 From: Yonghee Han Date: Wed, 28 Jun 2017 18:47:50 +0900 Subject: [PATCH] Add a purge rule for smr project Define : SMR_PURGE_PRJ_HOUR Rule : find "Tizen" and "smr" and is not "Base" Change-Id: I6a9d08d86a16fd6375f6421c55ed568c8e9060c8 --- job_ref_purge_prj_obs.py | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/job_ref_purge_prj_obs.py b/job_ref_purge_prj_obs.py index 9cd9910..43b35c1 100644 --- a/job_ref_purge_prj_obs.py +++ b/job_ref_purge_prj_obs.py @@ -81,23 +81,40 @@ def main(): now_datetime = datetime.now() #### Purge the reference project to obs ( 14day) #### - remove_hour = os.getenv("REF_PURGE_PRJ_HOUR") - for prj in prj_list: - create_datetime = datetime.strptime(prj.split(':')[-1], "%Y%m%d.%H") - #print create_datetime - post_hour = divmod((now_datetime - create_datetime).total_seconds(), 3600)[0] - if int(post_hour) > int(remove_hour): - cleanup = True - for reftarget in obs_ref_prjs: - #print 'ref=%s prj=%s' %(reftarget['OBS_staging_project'],prj) - if reftarget['OBS_staging_project'] == prj: - cleanup = False - break - if cleanup: + if os.getenv("REF_PURGE_PRJ_HOUR"): + remove_hour = os.getenv("REF_PURGE_PRJ_HOUR") + for prj in prj_list: + create_datetime = datetime.strptime(prj.split(':')[-1], "%Y%m%d.%H") + #print create_datetime + post_hour = divmod((now_datetime - create_datetime).total_seconds(), 3600)[0] + if int(post_hour) > int(remove_hour): + cleanup = True + for reftarget in obs_ref_prjs: + #print 'ref=%s prj=%s' %(reftarget['OBS_staging_project'],prj) + if reftarget['OBS_staging_project'] == prj: + cleanup = False + break + if cleanup: + build.cleanup(prj, "This project has expired") + print "%s project is remove." % prj + else: + print "%s project is reference project. Skip remove project !!!!" % prj + + #### Purge SMR Project #### + smr_prj_list = [ obj for obj in build.get_package_list("") \ + if not obj.find("Tizen:") == -1 \ + and not obj.find(":smr:") == -1 \ + and obj.find(":Base:") == -1 ] + + if os.getenv("SMR_PURGE_PRJ_HOUR"): + remove_hour = os.getenv("SMR_PURGE_PRJ_HOUR") + for prj in smr_prj_list: + create_datetime = datetime.strptime(prj.split(':')[-1], "%Y%m%d.%H") + #print create_datetime + post_hour = divmod((now_datetime - create_datetime).total_seconds(), 3600)[0] + if int(post_hour) > int(remove_hour): build.cleanup(prj, "This project has expired") print "%s project is remove." % prj - else: - print "%s project is reference project. Skip remove project !!!!" % prj return -- 2.7.4