-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.py
executable file
·87 lines (67 loc) · 3.17 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python3
# Import ATC classes
try:
from scripts.populatemarkdown import DataPopulateMarkdown
from scripts.populateconfluence import DataPopulateConfluence
from scripts.yamls2csv import GenerateCSV
from scripts.generate_mkdocs_config import GenerateMkdocs
except:
from data.atc_data.scripts.populatemarkdown import DataPopulateMarkdown
from data.atc_data.scripts.populateconfluence import DataPopulateConfluence
from data.atc_data.scripts.yamls2csv import GenerateCSV
from data.atc_data.scripts.generate_mkdocs_config import GenerateMkdocs
# For confluence
from requests.auth import HTTPBasicAuth
# Others
import argparse
import getpass
import random
import string
import os
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="""Main function of ATC Data.
You can not only choose to export analytics but also to use different
modules.
""")
# Mutually exclusive group for chosing the output of the script
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-C', '--confluence', action='store_true',
help='Export analytics to Confluence')
group.add_argument('-M', '--markdown', action='store_true',
help='Export analytics to Markdown repository')
group.add_argument('-Y2C', '--yaml-to-csv', action='store_true',
help='Generate a CSV file out of yaml files')
group.add_argument('-MK', '--mkdocs', action='store_true',
help='Generate mkdocs navigation file')
# Mutually exclusive group for chosing type of data
group2 = parser.add_mutually_exclusive_group(required=False)
group2.add_argument('-A', '--auto', action='store_true',
help='Build full repository')
group2.add_argument('-LP', '--loggingpolicy', action='store_true',
help='Build logging policy part')
group2.add_argument('-DN', '--dataneeded', action='store_true',
help='Build data needed part')
group2.add_argument('-EN', '--enrichment', action='store_true',
help='Build enrichment part')
# Init capabilities
parser.add_argument('-i', '--init', action='store_true',
help="Build initial pages or directories " +
"depending on the export type")
args = parser.parse_args()
if args.markdown:
DataPopulateMarkdown(auto=args.auto, lp=args.loggingpolicy,
dn=args.dataneeded,en=args.enrichment,
init=args.init)
elif args.confluence:
print("Provide Confluence credentials\n")
mail = input("Login: ")
password = getpass.getpass(prompt='Password: ', stream=None)
auth = HTTPBasicAuth(mail, password)
DataPopulateConfluence(auth=auth, auto=args.auto, lp=args.loggingpolicy,
dn=args.dataneeded,en=args.enrichment,
init=args.init)
elif args.yaml_to_csv:
GenerateCSV()
elif args.mkdocs:
GenerateMkdocs()