Deny update results if result already set
Change-Id: Icc566041a407daf64ba39fc18fe97b7bd1e27781
Related-PROD: PROD-30826
diff --git a/daily_jenkins_job_report/daily_report/update_google_sheets.py b/daily_jenkins_job_report/daily_report/update_google_sheets.py
index 50af59b..c41880a 100644
--- a/daily_jenkins_job_report/daily_report/update_google_sheets.py
+++ b/daily_jenkins_job_report/daily_report/update_google_sheets.py
@@ -43,8 +43,10 @@
if upd['build_status'] == 'FAILURE':
upd['build_status'] = 'FAILED'
- print(datetime.fromtimestamp(upd['timestamp']), upd['full_job_name'], upd['build_status'])
- self.wks.update_acell(cell, upd['build_status'])
+ logger.info(f"{datetime.fromtimestamp(upd['timestamp'])}, {upd['full_job_name']}, {upd['build_status']}")
+
+ if not self.wks.acell(cell).value:
+ self.wks.update_acell(cell, upd['build_status'])
if gs['gs_job_name'] == upd['full_job_name'] and upd['build_status'] != 'None' and check_datetime_today(upd['timestamp']):
cell = column_to_update + str(gs['row_number'])
@@ -52,14 +54,18 @@
if upd['build_status'] == 'FAILURE':
upd['build_status'] = 'FAILED'
- print(datetime.fromtimestamp(upd['timestamp']), upd['full_job_name'], upd['build_status'])
- self.wks.update_acell(cell, upd['build_status'])
+ logger.info(f"{datetime.fromtimestamp(upd['timestamp'])}, {upd['full_job_name']}, {upd['build_status']}")
+
+ if not self.wks.acell(cell).value:
+ self.wks.update_acell(cell, upd['build_status'])
elif ("oscore-oscc-ci" not in upd['full_job_name']) and gs['gs_job_name'] == upd['full_job_name'] and upd['build_status'] != 'None' and not check_datetime_today(upd['timestamp']):
cell = column_to_update + str(gs['row_number'])
- print('NOT TOADAY', datetime.fromtimestamp(upd['timestamp']), upd['full_job_name'], upd['build_status'])
- self.wks.update_acell(cell, 'NOT EXEQUTED')
+ logger.info(f"NOT TOADAY: {datetime.fromtimestamp(upd['timestamp'])}, {upd['full_job_name']}, {upd['build_status']}")
+
+ if not self.wks.acell(cell).value:
+ self.wks.update_acell(cell, 'NOT EXEQUTED')
def get_all_gs_jobs(self, column_number='A'):
"""
@@ -81,15 +87,15 @@
If they are the same, returns column value from the list_of_columns
"""
logger.info('Getting date from gs')
- list_of_columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN',
- 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'BA']
+ list_of_columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+ 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AB', 'AC',
+ 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO',
+ 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'BA']
for i in list_of_columns:
cell = i + '3'
now = datetime.now()
if self.wks.acell(cell).value == now.strftime("%Y-%m-%d"):
- print(cell, i, self.wks.acell(cell).value)
+ logger.info(f"{cell}, {i}, {self.wks.acell(cell).value}")
return i
@@ -119,7 +125,6 @@
"""
If timestamp is appied for today - returns True
"""
- # logger.info('Checking datetime today')
to_date_obj = datetime.fromtimestamp(timestamp)
today = datetime.today().date()
@@ -140,4 +145,3 @@
gs = UpdateGoogleSheets()
column = gs.get_today_date_column()
gs.update_gs_jobs(all_gs_jobs, all_jobs, column)
-