diff --git a/createKeyRequestReport.py b/createKeyRequestReport.py index da95843..5bcb3d3 100644 --- a/createKeyRequestReport.py +++ b/createKeyRequestReport.py @@ -20,37 +20,10 @@ import types import SLO from patterns.Pattern1 import Pattern1, Pattern2, Pattern3 -# import importlib - -# from dynamic_import import * - -# from patterns import a warnings.filterwarnings("ignore") -# module = __import__("patterns.a") -# my_class = getattr(module, "a.APattern") -# instance = my_class() -# mod, modCl = dynamic_imp("patterns", "APattern") -# modCl.APattern("asdsad") -# path = os.path.dirname(os.path.abspath(__file__))+"/patterns" - -# for py in [f[:-3] for f in os.listdir(path) if f.endswith('.py') and f != '__init__.py']: -# mod = __import__('.'.join([__name__, py]), fromlist=[py]) -# classes = [getattr(mod, x) for x in dir(mod) if isinstance(getattr(mod, x), type)] -# for cls in classes: -# setattr(sys.modules[__name__], cls.__name__, cls) - -# module = importlib.import_module('patterns.a') -# my_class = getattr(module, 'MyClass') -# my_instance = my_class() -#warning, there are warnings which are ignored! - -# patterns=[ -# {"regex": "type\(\"?service_method\"?\),.*fromRelationship\.isServiceMethodOfService\(.*type\(\"?service\"?\),entityName\.in\(([^\)]*).*,entityName\.in\(([^\)]*)"} -# ]; - patterns=[Pattern1(), Pattern2(), Pattern3()] def get_request(url, headers): @@ -201,31 +174,6 @@ def write_slo_to_excel(args, fromDate, hourlyall, dailyall, totalall, ytd): writer.close() -def testProcess(matches): - services=[s.strip() for s in matches.group(1).split(",")] - methods=[s.strip() for s in matches.group(2).split(",")] - - query="type(service_method),fromRelationship.isServiceMethodOfService(type(\"SERVICE\"),entityName.in(\""+'","'.join(services)+"\")),entityName.in(\""+'","'.join(methods)+"\")" - -# env = DTENV -# DTAPIToken = DTAPIToken - - -# DTAPIURL = env + "/api/v2/apiTokens" - -# headers = { -# 'Content-Type': 'application/json', -# 'Authorization': 'Api-Token ' + DTAPIToken -# } - - -# data = '{"name":"' + tokenname + '","scopes":["InstallerDownload","ReadConfig","WriteConfig","DataExport"]}' -# #data = '{"name":"' + tokenname + '","scopes":["ReadConfig","DataExport","entities.read"]}' - -# r = post_request(DTAPIURL,headers,data, proxies) - - return - def parseAndCreateSLOObject(row): @@ -256,13 +204,6 @@ def normalize(x): return tmp -# def start(dfSLOS): -# #dfSLOS['normalizedMetricExpression']= dfSLOS.apply(lambda row : normalize(row['metricExpression'], row['filter'])) - -# for index, row in dfSLOS.iterrows(): -# #if row["id"]=="3a2d280d-83bb-3e45-bafc-e79c1429c79b": -# findKeyrequests(normalize(row['metricExpression'])) - def main(slo_path): with open('./environment.yaml') as file: @@ -292,55 +233,5 @@ def main(slo_path): x=0 - # slo_configs = load_slo_parameter(slo_path) - - # for one_slo_config in slo_configs: - # hub, selector_type, selector_var, yearstart, header_name = one_slo_config - # print(f"For the slo config was '{slo_path}' used with the config '{header_name}'.") - # for item, doc in env_doc.items(): - # if not item in hub: - # print(f"{item} will be skipped since it is not in {hub}, which was selected in {slo_path}") - # continue - # token = dict(doc[2]) - # url = dict(doc[1]) - # print("Crawling through: " + item) - # print("Check if token exists in environment...") - # if(config(token.get('env-token-name')) != ""): - # print("Gather data, hold on a minute") - # DTTOKEN = config(token.get('env-token-name')) - # DTURL = url.get('env-url') - - # ###Calc daily SLO - # if 'd' in str.lower(args.slices): - # dailyall = get_one_slice(item, DTTOKEN, DTURL, days, dailyall, selector_var, selector_type) - # #Calc hourly SLO - # if 'h' in str.lower(args.slices): - # hourlyall = get_one_slice(item, DTTOKEN, DTURL, hours, hourlyall, selector_var, selector_type) - # ###Calc Overall YTD SLO - # if 'y' in str.lower(args.slices): - # ytd = get_slice_ytd_total(DTTOKEN,DTURL,item, yearstart, days['endTime'].max(), 'Date', fromDate.year, ytd, selector_var, selector_type) - # ###Calc Overall SLO - # if 't' in str.lower(args.slices): - # totalall = get_slice_ytd_total(DTTOKEN,DTURL,item, days['startTime'].min(), days['endTime'].max(), 'Date', fromDate.isocalendar()[1], totalall, selector_var, selector_type) - # else: - # print("token not found, skipping " + item) - # write_slo_to_excel(args, fromDate, hourlyall, dailyall, totalall, ytd) - # print("It took {} seconds to run this script".format(time.time()-start_timer)) - if __name__ == "__main__": - - # for file in glob(os.path.join(os.path.dirname(os.path.abspath(__file__)), "*.py")): - # name = os.path.splitext(os.path.basename(file))[0] - # if name == "Animal" or name == "main": # avoid main.py and Animal.py - # continue - # # add package prefix to name, if required - # module = __import__(name) - # try: - # # get the class - # cls = getattr(module, name) - # # instantiate the class and call the method - # cls().feed() - # except Exception as e: - # print(e) - main('./slo_parameter.yaml') \ No newline at end of file