diff --git a/createKeyRequestReport.py b/createKeyRequestReport.py index 4b9c62e..9ab1214 100644 --- a/createKeyRequestReport.py +++ b/createKeyRequestReport.py @@ -58,89 +58,89 @@ def getSLO(ENV, DTAPIToken, DTENV): -def init_argparse(): - parser = argparse.ArgumentParser( - usage="%(prog)s [--fromDate] [toDate] or [preSelect]", - description="gather SLO in daily slices for given Timeframe" - ) - parser.add_argument( - "-f","--fromDate", - help = "YYYY-mm-dd e.g. 2022-01-01" - ) - parser.add_argument( - "-t","--toDate", - help = "YYYY-mm-dd e.g. 2022-01-31" - ) - parser.add_argument( - "-p","--preSelect", - help = "day | week | month - gathers the data for the last full day, week or month" - ) - parser.add_argument( - "-s","--slices", - help = "h | d | t | y - writes the slices hourly, daily, total or year to date into ecxel. given in any order" - ) +# def init_argparse(): +# parser = argparse.ArgumentParser( +# usage="%(prog)s [--fromDate] [toDate] or [preSelect]", +# description="gather SLO in daily slices for given Timeframe" +# ) +# parser.add_argument( +# "-f","--fromDate", +# help = "YYYY-mm-dd e.g. 2022-01-01" +# ) +# parser.add_argument( +# "-t","--toDate", +# help = "YYYY-mm-dd e.g. 2022-01-31" +# ) +# parser.add_argument( +# "-p","--preSelect", +# help = "day | week | month - gathers the data for the last full day, week or month" +# ) +# parser.add_argument( +# "-s","--slices", +# help = "h | d | t | y - writes the slices hourly, daily, total or year to date into ecxel. given in any order" +# ) - return parser +# return parser -def check_inputs(args): - ''' - This functions is the single point of true for arguments. If new arguments are added they need to be added in here. Returns from and to date. - ''' - if args.preSelect and (args.fromDate or args.toDate): - print("--preSelect must not be used in conjuntion with --fromDate and/or --toDate") - sys.exit() +# def check_inputs(args): +# ''' +# This functions is the single point of true for arguments. If new arguments are added they need to be added in here. Returns from and to date. +# ''' +# if args.preSelect and (args.fromDate or args.toDate): +# print("--preSelect must not be used in conjuntion with --fromDate and/or --toDate") +# sys.exit() - elif args.fromDate and not args.toDate: - print("--fromDate only in conjunction with --toDate") - sys.exit() +# elif args.fromDate and not args.toDate: +# print("--fromDate only in conjunction with --toDate") +# sys.exit() - elif args.toDate and not args.fromDate: - print("--toDate only in conjunction with --fromDate") - sys.exit() +# elif args.toDate and not args.fromDate: +# print("--toDate only in conjunction with --fromDate") +# sys.exit() - elif args.toDate and args.fromDate and not args.preSelect: - try: - #fromDate = datetime.date.fromisoformat(args.fromDate) - fromDate = datetime.datetime.strptime(args.fromDate, "%Y-%m-%d") +# elif args.toDate and args.fromDate and not args.preSelect: +# try: +# #fromDate = datetime.date.fromisoformat(args.fromDate) +# fromDate = datetime.datetime.strptime(args.fromDate, "%Y-%m-%d") - #toDate = datetime.date.fromisoformat(args.toDate) - toDate = datetime.datetime.strptime(args.toDate, "%Y-%m-%d") - except Exception as e: - print("Progam closed: " + str(e)) - sys.exit() +# #toDate = datetime.date.fromisoformat(args.toDate) +# toDate = datetime.datetime.strptime(args.toDate, "%Y-%m-%d") +# except Exception as e: +# print("Progam closed: " + str(e)) +# sys.exit() - if toDate < fromDate: - print("--toDate can't be older than --fromDate") - sys.exit() +# if toDate < fromDate: +# print("--toDate can't be older than --fromDate") +# sys.exit() - if toDate > datetime.date.today() or fromDate > datetime.date.today(): - print("--toDate or --fromDate can't be in the future") - sys.exit() +# if toDate > datetime.date.today() or fromDate > datetime.date.today(): +# print("--toDate or --fromDate can't be in the future") +# sys.exit() - elif args.preSelect and not args.fromDate and not args.toDate: +# elif args.preSelect and not args.fromDate and not args.toDate: - date = datetime.date.today() +# date = datetime.date.today() - if args.preSelect == "week": - fromDate, toDate = previous_week_range(date) - elif args.preSelect == "month": - fromDate, toDate = previous_month_range(date) - elif args.preSelect == "day": - fromDate, toDate = previous_day_range(date) - else: - print("--preSelect must be week or month") - sys.exit() - else: - print("Invalid arguments, please use --help") - sys.exit() - if args.slices == None: - print("-s or --slices must not be null and needs at least one letter of h d t or y, lower- or uppercase.") - sys.exit() - elif sum([1 if one_inp in str.lower(args.slices) else 0 for one_inp in ['h','d','t','y'] ]) == 0: - print("-s or --slices must has at least one letter of h d t or y, lower- or uppercase.") - sys.exit() - return fromDate, toDate +# if args.preSelect == "week": +# fromDate, toDate = previous_week_range(date) +# elif args.preSelect == "month": +# fromDate, toDate = previous_month_range(date) +# elif args.preSelect == "day": +# fromDate, toDate = previous_day_range(date) +# else: +# print("--preSelect must be week or month") +# sys.exit() +# else: +# print("Invalid arguments, please use --help") +# sys.exit() +# if args.slices == None: +# print("-s or --slices must not be null and needs at least one letter of h d t or y, lower- or uppercase.") +# sys.exit() +# elif sum([1 if one_inp in str.lower(args.slices) else 0 for one_inp in ['h','d','t','y'] ]) == 0: +# print("-s or --slices must has at least one letter of h d t or y, lower- or uppercase.") +# sys.exit() +# return fromDate, toDate @@ -157,8 +157,6 @@ def applyPatterns(subject): break return groups - - def parseAndCreateSLOObject(row): @@ -224,8 +222,6 @@ def getParsedSLOs(ENV, DTTOKEN, DTURL): for index, row in slosF.iterrows(): #if row['id'] == "06292149-0f7f-34f6-b226-dfd9f680486d": #or row['id'] == "ab1bf34a-10fc-3446-9cc7-79d257498a52": slos.append(parseAndCreateSLOObject(row)) - #print("filter:"+row["filter"]) - return slos def write_to_excel(ignored, notExists):