Merge "Merge branch 'master' of ssh://gerrit.mcp.mirantis.com:29418/mcp/osccore-qa-testing-tools into google"
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a67fbbd
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.pyc
+.i*
+.v*
+oscore-e717344565a0.json
\ No newline at end of file
diff --git a/daily_jenkins_job_report/__init__.py b/daily_jenkins_job_report/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/daily_jenkins_job_report/__init__.py
diff --git a/daily_jenkins_job_report/daily_report/generate_report.py b/daily_jenkins_job_report/daily_report/generate_report.py
index 3b6e93f..c0c5ed5 100644
--- a/daily_jenkins_job_report/daily_report/generate_report.py
+++ b/daily_jenkins_job_report/daily_report/generate_report.py
@@ -204,6 +204,8 @@
if __name__ == '__main__':
all_jobs_results = get_all_jobs_results()
- print(all_jobs_results)
+
+ print('all_jobs_results', all_jobs_results)
+
save_results_to_html(all_jobs_results)
update_google_sheets.update_google_sheet(all_jobs_results)
diff --git a/daily_jenkins_job_report/daily_report/requirements.txt b/daily_jenkins_job_report/daily_report/requirements.txt
deleted file mode 100644
index f1cbc3a..0000000
--- a/daily_jenkins_job_report/daily_report/requirements.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-nsapi>=0.3.6
-jinja2>=2.10
-setuptools>=40.8.0
-gspread>=3.1.0
-oauth2client>=4.1.3
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 5661efc..ca8a52d 100644
--- a/daily_jenkins_job_report/daily_report/update_google_sheets.py
+++ b/daily_jenkins_job_report/daily_report/update_google_sheets.py
@@ -28,52 +28,31 @@
self.wks = gc.open('OSCORE QA daily reports').worksheet(config.GOOGLE_SHEET_NAME)
logger.info('Opening OSCORE QA daily reports for May 2019')
- def get_gs_jobs_list(self, gs_jobs):
- """
- Gets google sheet jobs list from the first column
- returns list of jobs
- """
- logger.info('Getting google sheet jobs list from the first column')
- gs_jobs_list = []
- for i in gs_jobs:
- gs_jobs_list.append(i['gs_job_name'])
- return gs_jobs_list
-
- def get_gobs_for_update(self, all_jobs_results, gs_jobs):
- """
- Gets google sheet jobs for updating.
- returns list of jobs for update
- """
- logger.info('Getting google sheet jobs for updating')
- jobs_for_update = []
- gs_jobs_list = self.get_gs_jobs_list(gs_jobs)
-
- for key, value in all_jobs_results['multi_results'].items():
- for i in all_jobs_results['multi_results'][key]:
-
- if i['job_name'] in gs_jobs_list:
- jobs_for_update.append(i)
- return jobs_for_update
-
def update_gs_jobs(self, gs_jobs, jobs_for_update, column_to_update):
"""
Updates google sheet column with jobs
"""
logger.info('Updating google sheet jobs')
- for upd in jobs_for_update:
- for gs in gs_jobs:
- if gs['gs_job_name'] == upd['job_name'] and upd['build_status'] != 'None' and check_datetime_today(upd['timestamp']):
+ for gs in gs_jobs:
+ for all_jobs in jobs_for_update['multi_results']:
+ for upd in jobs_for_update['multi_results'][all_jobs]:
+ 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'])
+
if upd['build_status'] == 'FAILURE':
upd['build_status'] = 'FAILED'
- self.wks.update_acell(cell, upd['build_status'])
- print( self.wks.acell(cell).value)
- if not check_datetime_today(upd['timestamp']):
- cell = column_to_update + str(gs['row_number'])
- self.wks.update_acell(cell, 'NOT EXEQUTED')
- def get_all_jobs(self, column_number='A'):
+ print(datetime.fromtimestamp(upd['timestamp']), upd['full_job_name'], upd['build_status'])
+ self.wks.update_acell(cell, upd['build_status'])
+
+ elif 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')
+
+ def get_all_gs_jobs(self, column_number='A'):
"""
Gets all the google sheet jobs for updating from the first column
"""
@@ -117,10 +96,10 @@
version = i['baseurl'][72:]
version = version[:version.find("/")]
new_name = key + '_' + i['job_name'] + version
- i['job_name'] = new_name
+ i['full_job_name'] = new_name
else:
new_name = key + '_' + i['job_name']
- i['job_name'] = new_name
+ i['full_job_name'] = new_name
return results
@@ -129,30 +108,25 @@
"""
If timestamp is appied for today - returns True
"""
- logger.info('Checking datetime today')
+ # logger.info('Checking datetime today')
to_date_obj = datetime.fromtimestamp(timestamp)
- yesterday = datetime.now() - timedelta(days=1)
+ today = datetime.today().date()
+ yesterday = datetime.today().date() - timedelta(days=1)
# Returns True or False
- return to_date_obj.date() == datetime.today().date() or \
- to_date_obj.date() == datetime.today().date() - timedelta(days=1)
-
-
+ return to_date_obj.date() == today
def update_google_sheet(all_jobs_results):
"""
The main function for updating google sheets.
All the functions for updating are here
"""
+
all_gs_jobs = config.ALL_GS_JOBS
- update_multy_job_names(all_jobs_results)
+ all_jobs = update_multy_job_names(all_jobs_results)
+
gs = UpdateGoogleSheets()
-
- # all_gs_jobs = gs.get_gs_jobs_list(gs_jobs)
- jobs_for_update = gs.get_gobs_for_update(all_jobs_results, all_gs_jobs)
-
column = gs.get_today_date_column()
-
- gs.update_gs_jobs(all_gs_jobs, jobs_for_update, column)
+ gs.update_gs_jobs(all_gs_jobs, all_jobs, column)
diff --git a/daily_jenkins_job_report/requirements.txt b/daily_jenkins_job_report/requirements.txt
index aebbc58..c114e41 100644
--- a/daily_jenkins_job_report/requirements.txt
+++ b/daily_jenkins_job_report/requirements.txt
@@ -1,3 +1,7 @@
+gspread>=3.1.0
jenkinsapi>=0.3.6
jinja2>=2.10
-setuptools>=40.8.0
\ No newline at end of file
+nsapi>=0.3.6
+oauth2client>=4.1.3
+setuptools>=40.8.0
+ipdb>=0.12
\ No newline at end of file