-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsecure-crt-python.py
80 lines (63 loc) · 2.67 KB
/
secure-crt-python.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
# $language = "python"
# $interface = "1.0"
import logging
import sys
import os
from shutil import copy2
this_script_path = os.path.abspath(os.path.dirname(__file__))
if not this_script_path in sys.path:
sys.path.insert(0, this_script_path)
import modules as mod
__status__ = 'dev'
__version_info__ = (1, 0, 0)
__version__ = '.'.join(map(str, __version_info__))
__maintainer__ = 'Benjamin P. Trachtenberg'
__email__ = '[email protected]'
LOGGER = logging.getLogger(__name__)
def main():
"""
Main Function
:return:
None
"""
make_logger()
start_control()
def start_control():
LOGGER.debug('Starting start_control()')
ticket_number = None
global_data_obj = mod.GlobalData()
message_box = mod.CustomMessageBox('Is this for a ticket?', title='Ticket', buttons=4, crt=crt)
button_click = message_box.get_message_box()
if button_click == 6:
prompt = mod.CustomPromptBox('What is the ticket number, or folder you want to save data to?',
title='Ticket Number' ,crt=crt)
ticket_number = prompt.get_message_box().upper()
try:
prompt = mod.CustomPromptBox('What is the OS of the device? Example: ios, nxos, or exit',
title='OS Type Entry', crt=crt)
os_type = None
while os_type not in ('IOS',):
os_type = prompt.get_message_box().upper()
LOGGER.debug('Found OS type {}'.format(os_type))
if os_type in ('IOS',):
mod.Ios(crt=crt, ticket=ticket_number)
elif os_type in ('NXOS', 'NX-OS', 'NEXUS'):
mod.Nexus(crt=crt, ticket=ticket_number)
elif os_type in ('XR', 'IOS-XR', 'IOSXR'):
mod.IosXr(crt=crt, ticket=ticket_number)
elif os_type == 'EXIT':
message_box = mod.CustomMessageBox('Do yu want to stop running the script?', title='Exit Script',
buttons=4, crt=crt)
button_click = message_box.get_message_box()
if button_click == 6:
break
except Exception as e:
LOGGER.critical(e)
def make_logger():
logging.basicConfig(format='%(asctime)s: %(name)s - %(levelname)s - %(message)s',
filename=os.path.join(os.path.join(mod.get_win_registry_key('Software\VanDyke\SecureCRT',
'Config Path'),
'Logs', 'securecrt-script-logs.txt')))
logging.getLogger().setLevel(logging.DEBUG)
LOGGER.warning('Logging Started!!')
main()