#/* # * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more # * contributor license agreements. See the NOTICE file distributed with # * this work for additional information regarding copyright ownership. # * The OpenAirInterface Software Alliance licenses this file to You under # * the OAI Public License, Version 1.1 (the "License"); you may not use this file # * except in compliance with the License. # * You may obtain a copy of the License at # * # * http://www.openairinterface.org/?page_id=698 # * # * Unless required by applicable law or agreed to in writing, software # * distributed under the License is distributed on an "AS IS" BASIS, # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # * See the License for the specific language governing permissions and # * limitations under the License. # *------------------------------------------------------------------------------- # * For more information about the OpenAirInterface (OAI) Software Alliance: # * contact@openairinterface.org # */ #--------------------------------------------------------------------- # Merge Requests Dashboard for RAN on googleSheet # # Required Python Version # Python 3.x # #--------------------------------------------------------------------- #----------------------------------------------------------- # Import #----------------------------------------------------------- #Author Remi import boto3 import shlex import subprocess import json #json structures import datetime #now() and date formating from datetime import datetime import re import gitlab import yaml import os import time from sqlconnect import SQLConnect #----------------------------------------------------------- # Class Declaration #----------------------------------------------------------- class Dashboard: def __init__(self): #init with data sources : git, yaml config file, test results databases print("Collecting Data") cmd="""curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100" """ self.git = self.__getGitData(cmd) #git data from Gitlab self.tests = self.__loadCfg('ran_dashboard_cfg.yaml') #tests table setup from yaml self.db = self.__loadFromDB() #test results from database def __loadCfg(self,yaml_file): with open(yaml_file,'r') as f: tests = yaml.load(f) return tests def __getGitData(self,cmd): #cmd="""curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100" """ process = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) output = process.stdout.readline() tmp=output.decode("utf-8") d = json.loads(tmp) return d def __loadFromDB(self): mr_list=[] for x in range(len(self.git)): mr_list.append(str(self.git[x]['iid'])) mydb=SQLConnect() for MR in mr_list: mydb.get(MR) mydb.close_connection() return mydb.data def Test_initHTML(self, date): self.f_html.write('\n') self.f_html.write('
\n') self.f_html.write('\n') self.f_html.write('| OAI RAN TEST Status Dashboard | \n') self.f_html.write('\n') self.f_html.write('
| Merge Requests Dashboard | \n') self.f_html.write('\n') self.f_html.write('
| Update : '+date+' | \n') self.f_html.write('\n') self.f_html.write('