tsbuddy 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tsbuddy-0.0.3/PKG-INFO ADDED
@@ -0,0 +1,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: tsbuddy
3
+ Version: 0.0.3
4
+ Description-Content-Type: text/markdown
5
+ Dynamic: description
6
+ Dynamic: description-content-type
7
+
8
+ # Tech Support Buddy (`tsbuddy`)
9
+
10
+ [![PyPI version](https://badge.fury.io/py/tsbuddy.svg)](https://badge.fury.io/py/tsbuddy)
11
+ <!-- Add other badges as appropriate: build status, coverage, etc. -->
12
+ <!-- e.g., [![Build Status](https://travis-ci.org/YOUR_USERNAME/tsbuddy.svg?branch=main)](https://travis-ci.org/YOUR_USERNAME/tsbuddy) -->
13
+
14
+ Tech Support Buddy is a versatile Python module built to empower developers and IT professionals in resolving technical issues. It provides a suite of Python functions designed to efficiently diagnose and resolve technical issues by parsing raw text into structured data, enabling automation and data-driven decision-making.
15
+
16
+ ## Table of Contents
17
+
18
+ - [Overview](#overview)
19
+ - [Key Features](#key-features)
20
+ - [Installation](#installation)
21
+ - [Usage](#usage)
22
+ - [Basic Example: Parsing Temperature Data](#basic-example-parsing-temperature-data)
23
+ - [Future Enhancements (Ideas)](#future-enhancements-examples)
24
+ - [Contributing](#contributing)
25
+
26
+ ## Overview
27
+
28
+ Dealing with raw text output can be tedious and time-consuming. `tsbuddy` parsing aims to simplify this by providing tools to:
29
+
30
+ 1. **Extract** relevant sections from log files or command output.
31
+ 2. **Parse** this raw text into structured Python objects.
32
+ 3. **Enable** programmatic analysis and decision-making based on the parsed data.
33
+
34
+ This allows you to quickly turn unstructured command output into actionable insights.
35
+
36
+ ## Key Features
37
+
38
+ * **Log Section Extraction:** Easily isolate specific command output or sections from larger support files.
39
+ * **Structured Data Parsing:** Convert unstructured command output into Python objects for easy manipulation. (Simple example below).
40
+ * **Simplified Diagnostics:** Build custom logic on top of parsed data to automate checks, generate reports, trigger alerts or actions.
41
+ * **Developer-Friendly:** Designed to be easily integrated into existing Python scripts and workflows.
42
+
43
+ ## Installation
44
+
45
+ You can install `tsbuddy` via pip:
46
+
47
+ ```bash
48
+ pip install tsbuddy
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ tsbuddy can be run directly from your preferred terminal. Doing so will run the main() function where tsbuddy will search for tech_support.log in your working directory & output its contents to a CSV.
54
+
55
+ ```powershell
56
+ (venv) admin:~/tech_support_complete$ tsbuddy
57
+ ✅ CSV exported to parsed_sections_2025-05-30_220933.csv
58
+ ```
59
+
60
+ Here's a basic example demonstrating how to use `tsbuddy` within Python to parse temperature information from command output.
61
+
62
+ ### Basic Example: Parsing Temperature Data
63
+
64
+ For this example, we will use a file named `tech_support.log` in your working directory.
65
+
66
+ **1. Import `tsbuddy` and `pprint`:**
67
+
68
+ ```python
69
+ import tsbuddy as ts
70
+ from pprint import pprint
71
+ ```
72
+
73
+ **2. Read your log file:**
74
+
75
+ (For this example, we'll simulate reading from the file. `tsbuddy` itself can work on any source of text.)
76
+
77
+ ```python
78
+ # Example content for 'tech_support.log' stored in the file_text variable
79
+ # This would typically be read from the actual file
80
+ file_text = """
81
+ Some initial lines...
82
+ show system, show chassis, etc
83
+
84
+ show temperature
85
+ Chassis/Device Current Range Danger Thresh Status
86
+ ---------------- ------- ---------- ------ ------ ---------------
87
+ 1/CMMA 47 15 to 60 68 60 UNDER THRESHOLD
88
+ 3/CMMA 46 15 to 60 68 60 UNDER THRESHOLD
89
+ 4/CMMA 46 15 to 60 68 60 UNDER THRESHOLD
90
+
91
+
92
+ Some other lines...
93
+ show ip interface, etc
94
+ ...
95
+ """
96
+ ```
97
+ <!-- # If you were reading from a file:
98
+ # file = "tech_support.log"
99
+ # with open(file, encoding='utf-8') as f:
100
+ # file_text = f.read()
101
+ -->
102
+
103
+ **3. Extract the relevant section:**
104
+
105
+ The `extract_section` function helps you get the raw text for a specific command or section.
106
+
107
+ ```python
108
+ # Extract the section containing "show temperature" output
109
+ temp_section_text = ts.extract_section(file_text, "show temperature")
110
+
111
+ # print("--- Raw Extracted Text ---")
112
+ # print(temp_section_text)
113
+ ## Seen above, without other section output
114
+ ```
115
+
116
+ **4. Parse the raw text into a structured format:**
117
+
118
+ `tsbuddy` provides parsers for specific commands. Here, we use `parse_temperature`.
119
+
120
+ ```python
121
+ # Parse the raw temperature text to structured data
122
+ parsed_temps = ts.parse_temperature(temp_section_text)
123
+
124
+ print("--- Parsed Temperature Data ---")
125
+ pprint(parsed_temps, sort_dicts=False)
126
+ ```
127
+
128
+ This will output:
129
+
130
+ ```
131
+ --- Parsed Temperature Data ---
132
+ [{'Chassis/Device': '1/CMMA',
133
+ 'Current': '47',
134
+ 'Range': '15 to 60',
135
+ 'Danger': '68',
136
+ 'Thresh': '60',
137
+ 'Status': 'UNDER THRESHOLD'},
138
+ {'Chassis/Device': '3/CMMA',
139
+ 'Current': '46',
140
+ 'Range': '15 to 60',
141
+ 'Danger': '68',
142
+ 'Thresh': '60',
143
+ 'Status': 'UNDER THRESHOLD'},
144
+ {'Chassis/Device': '4/CMMA',
145
+ 'Current': '46',
146
+ 'Range': '15 to 60',
147
+ 'Danger': '68',
148
+ 'Thresh': '60',
149
+ 'Status': 'UNDER THRESHOLD'}]
150
+ ```
151
+
152
+ **5. Work with the structured data:**
153
+
154
+ Now that the data is structured, you can easily access and process specific fields.
155
+
156
+ ```python
157
+ # Request data from specific fields
158
+ print("\n--- Device Statuses ---")
159
+ for chassis in parsed_temps:
160
+ print(chassis["Status"])
161
+ ```
162
+
163
+ Output:
164
+
165
+ ```
166
+ --- Device Statuses ---
167
+ UNDER THRESHOLD
168
+ UNDER THRESHOLD
169
+ UNDER THRESHOLD
170
+ ```
171
+
172
+ **6. Add custom logic:**
173
+
174
+ You can build more complex logic based on the values of specific fields.
175
+
176
+ ```python
177
+ print("\n--- Devices with Current Temperature greater than 46°C ---")
178
+ for chassis in parsed_temps:
179
+ if int(chassis["Current"]) > 46:
180
+ print(chassis["Chassis/Device"] + " is greater than 46°C")
181
+ ```
182
+ <!-- pprint(chassis, sort_dicts=False)
183
+ -->
184
+
185
+ Output:
186
+
187
+ ```
188
+ --- Devices with Current Temperature greater than 46°C ---
189
+ 1/CMMA is greater than 46°C
190
+ ```
191
+ <!--
192
+ {'Chassis/Device': '1/CMMA',
193
+ 'Current': '47',
194
+ 'Range': '15 to 60',
195
+ 'Danger': '68',
196
+ 'Thresh': '60',
197
+ 'Status': 'UNDER THRESHOLD'}
198
+ -->
199
+
200
+ ## Future Enhancements (Examples)
201
+
202
+ The `tsbuddy` module is designed to be extensible. Future development could include:
203
+
204
+ * More parsers for common log outputs (e.g., `show fabric`, `vrf ... show ...`, `debug show ...`).
205
+ * Functions to compare states (e.g., before/after changes).
206
+ * Integration with alerting systems.
207
+ * Parse configuration.
208
+ * Convert configurations.
209
+ * Auto-detect parsing function.
210
+ * Generate tech-support & validate generation.
211
+ * Support outputting to MS Excel.
212
+ * Support for different log formats & devices.
213
+ * More sophisticated section extraction logic.
214
+
215
+ ## Contributing
216
+
217
+ Contributions are welcome! If you have ideas for improvements or new features, or if you've found a bug, please feel free to:
218
+
219
+ 1. Fork the repository.
220
+ 2. Create a new branch (`git checkout -b feature/YourFeature` or `bugfix/YourBugfix`).
221
+ 3. Make your changes.
222
+ 4. Commit your changes (`git commit -m 'Add some feature'`).
223
+ 5. Push to the branch (`git push origin feature/YourFeature`).
224
+ 6. Open a Pull Request.
225
+
226
+ Please ensure your code adheres to any existing style guidelines and includes tests where appropriate.
@@ -0,0 +1,219 @@
1
+ # Tech Support Buddy (`tsbuddy`)
2
+
3
+ [![PyPI version](https://badge.fury.io/py/tsbuddy.svg)](https://badge.fury.io/py/tsbuddy)
4
+ <!-- Add other badges as appropriate: build status, coverage, etc. -->
5
+ <!-- e.g., [![Build Status](https://travis-ci.org/YOUR_USERNAME/tsbuddy.svg?branch=main)](https://travis-ci.org/YOUR_USERNAME/tsbuddy) -->
6
+
7
+ Tech Support Buddy is a versatile Python module built to empower developers and IT professionals in resolving technical issues. It provides a suite of Python functions designed to efficiently diagnose and resolve technical issues by parsing raw text into structured data, enabling automation and data-driven decision-making.
8
+
9
+ ## Table of Contents
10
+
11
+ - [Overview](#overview)
12
+ - [Key Features](#key-features)
13
+ - [Installation](#installation)
14
+ - [Usage](#usage)
15
+ - [Basic Example: Parsing Temperature Data](#basic-example-parsing-temperature-data)
16
+ - [Future Enhancements (Ideas)](#future-enhancements-examples)
17
+ - [Contributing](#contributing)
18
+
19
+ ## Overview
20
+
21
+ Dealing with raw text output can be tedious and time-consuming. `tsbuddy` parsing aims to simplify this by providing tools to:
22
+
23
+ 1. **Extract** relevant sections from log files or command output.
24
+ 2. **Parse** this raw text into structured Python objects.
25
+ 3. **Enable** programmatic analysis and decision-making based on the parsed data.
26
+
27
+ This allows you to quickly turn unstructured command output into actionable insights.
28
+
29
+ ## Key Features
30
+
31
+ * **Log Section Extraction:** Easily isolate specific command output or sections from larger support files.
32
+ * **Structured Data Parsing:** Convert unstructured command output into Python objects for easy manipulation. (Simple example below).
33
+ * **Simplified Diagnostics:** Build custom logic on top of parsed data to automate checks, generate reports, trigger alerts or actions.
34
+ * **Developer-Friendly:** Designed to be easily integrated into existing Python scripts and workflows.
35
+
36
+ ## Installation
37
+
38
+ You can install `tsbuddy` via pip:
39
+
40
+ ```bash
41
+ pip install tsbuddy
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ tsbuddy can be run directly from your preferred terminal. Doing so will run the main() function where tsbuddy will search for tech_support.log in your working directory & output its contents to a CSV.
47
+
48
+ ```powershell
49
+ (venv) admin:~/tech_support_complete$ tsbuddy
50
+ ✅ CSV exported to parsed_sections_2025-05-30_220933.csv
51
+ ```
52
+
53
+ Here's a basic example demonstrating how to use `tsbuddy` within Python to parse temperature information from command output.
54
+
55
+ ### Basic Example: Parsing Temperature Data
56
+
57
+ For this example, we will use a file named `tech_support.log` in your working directory.
58
+
59
+ **1. Import `tsbuddy` and `pprint`:**
60
+
61
+ ```python
62
+ import tsbuddy as ts
63
+ from pprint import pprint
64
+ ```
65
+
66
+ **2. Read your log file:**
67
+
68
+ (For this example, we'll simulate reading from the file. `tsbuddy` itself can work on any source of text.)
69
+
70
+ ```python
71
+ # Example content for 'tech_support.log' stored in the file_text variable
72
+ # This would typically be read from the actual file
73
+ file_text = """
74
+ Some initial lines...
75
+ show system, show chassis, etc
76
+
77
+ show temperature
78
+ Chassis/Device Current Range Danger Thresh Status
79
+ ---------------- ------- ---------- ------ ------ ---------------
80
+ 1/CMMA 47 15 to 60 68 60 UNDER THRESHOLD
81
+ 3/CMMA 46 15 to 60 68 60 UNDER THRESHOLD
82
+ 4/CMMA 46 15 to 60 68 60 UNDER THRESHOLD
83
+
84
+
85
+ Some other lines...
86
+ show ip interface, etc
87
+ ...
88
+ """
89
+ ```
90
+ <!-- # If you were reading from a file:
91
+ # file = "tech_support.log"
92
+ # with open(file, encoding='utf-8') as f:
93
+ # file_text = f.read()
94
+ -->
95
+
96
+ **3. Extract the relevant section:**
97
+
98
+ The `extract_section` function helps you get the raw text for a specific command or section.
99
+
100
+ ```python
101
+ # Extract the section containing "show temperature" output
102
+ temp_section_text = ts.extract_section(file_text, "show temperature")
103
+
104
+ # print("--- Raw Extracted Text ---")
105
+ # print(temp_section_text)
106
+ ## Seen above, without other section output
107
+ ```
108
+
109
+ **4. Parse the raw text into a structured format:**
110
+
111
+ `tsbuddy` provides parsers for specific commands. Here, we use `parse_temperature`.
112
+
113
+ ```python
114
+ # Parse the raw temperature text to structured data
115
+ parsed_temps = ts.parse_temperature(temp_section_text)
116
+
117
+ print("--- Parsed Temperature Data ---")
118
+ pprint(parsed_temps, sort_dicts=False)
119
+ ```
120
+
121
+ This will output:
122
+
123
+ ```
124
+ --- Parsed Temperature Data ---
125
+ [{'Chassis/Device': '1/CMMA',
126
+ 'Current': '47',
127
+ 'Range': '15 to 60',
128
+ 'Danger': '68',
129
+ 'Thresh': '60',
130
+ 'Status': 'UNDER THRESHOLD'},
131
+ {'Chassis/Device': '3/CMMA',
132
+ 'Current': '46',
133
+ 'Range': '15 to 60',
134
+ 'Danger': '68',
135
+ 'Thresh': '60',
136
+ 'Status': 'UNDER THRESHOLD'},
137
+ {'Chassis/Device': '4/CMMA',
138
+ 'Current': '46',
139
+ 'Range': '15 to 60',
140
+ 'Danger': '68',
141
+ 'Thresh': '60',
142
+ 'Status': 'UNDER THRESHOLD'}]
143
+ ```
144
+
145
+ **5. Work with the structured data:**
146
+
147
+ Now that the data is structured, you can easily access and process specific fields.
148
+
149
+ ```python
150
+ # Request data from specific fields
151
+ print("\n--- Device Statuses ---")
152
+ for chassis in parsed_temps:
153
+ print(chassis["Status"])
154
+ ```
155
+
156
+ Output:
157
+
158
+ ```
159
+ --- Device Statuses ---
160
+ UNDER THRESHOLD
161
+ UNDER THRESHOLD
162
+ UNDER THRESHOLD
163
+ ```
164
+
165
+ **6. Add custom logic:**
166
+
167
+ You can build more complex logic based on the values of specific fields.
168
+
169
+ ```python
170
+ print("\n--- Devices with Current Temperature greater than 46°C ---")
171
+ for chassis in parsed_temps:
172
+ if int(chassis["Current"]) > 46:
173
+ print(chassis["Chassis/Device"] + " is greater than 46°C")
174
+ ```
175
+ <!-- pprint(chassis, sort_dicts=False)
176
+ -->
177
+
178
+ Output:
179
+
180
+ ```
181
+ --- Devices with Current Temperature greater than 46°C ---
182
+ 1/CMMA is greater than 46°C
183
+ ```
184
+ <!--
185
+ {'Chassis/Device': '1/CMMA',
186
+ 'Current': '47',
187
+ 'Range': '15 to 60',
188
+ 'Danger': '68',
189
+ 'Thresh': '60',
190
+ 'Status': 'UNDER THRESHOLD'}
191
+ -->
192
+
193
+ ## Future Enhancements (Examples)
194
+
195
+ The `tsbuddy` module is designed to be extensible. Future development could include:
196
+
197
+ * More parsers for common log outputs (e.g., `show fabric`, `vrf ... show ...`, `debug show ...`).
198
+ * Functions to compare states (e.g., before/after changes).
199
+ * Integration with alerting systems.
200
+ * Parse configuration.
201
+ * Convert configurations.
202
+ * Auto-detect parsing function.
203
+ * Generate tech-support & validate generation.
204
+ * Support outputting to MS Excel.
205
+ * Support for different log formats & devices.
206
+ * More sophisticated section extraction logic.
207
+
208
+ ## Contributing
209
+
210
+ Contributions are welcome! If you have ideas for improvements or new features, or if you've found a bug, please feel free to:
211
+
212
+ 1. Fork the repository.
213
+ 2. Create a new branch (`git checkout -b feature/YourFeature` or `bugfix/YourBugfix`).
214
+ 3. Make your changes.
215
+ 4. Commit your changes (`git commit -m 'Add some feature'`).
216
+ 5. Push to the branch (`git push origin feature/YourFeature`).
217
+ 6. Open a Pull Request.
218
+
219
+ Please ensure your code adheres to any existing style guidelines and includes tests where appropriate.
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
tsbuddy-0.0.3/setup.py ADDED
@@ -0,0 +1,21 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open('README.md', 'r') as f:
4
+ long_description = f.read()
5
+
6
+ setup(
7
+ name='tsbuddy',
8
+ version='0.0.3',
9
+ packages=find_packages(),
10
+ install_requires=[
11
+ # Add dependencies here.
12
+ # e.g. 'numpy>=1.11.1'
13
+ ],
14
+ entry_points={
15
+ 'console_scripts': [
16
+ 'tsbuddy=tsbuddy.tsbuddy:main',
17
+ ],
18
+ },
19
+ long_description=long_description,
20
+ long_description_content_type='text/markdown',
21
+ )
@@ -0,0 +1,50 @@
1
+ from .tsbuddy import export_to_csv
2
+ from .tsbuddy import extract_section
3
+ from .tsbuddy import parse_sections
4
+ from .tsbuddy import main
5
+ from .tsbuddy import parse_aaa_authentication
6
+ from .tsbuddy import parse_appmgr
7
+ from .tsbuddy import parse_capability_naas
8
+ from .tsbuddy import parse_capability_profile
9
+ from .tsbuddy import parse_chassis
10
+ from .tsbuddy import parse_debug_virtual_chassis_connection
11
+ from .tsbuddy import parse_debug_virtual_chassis_status
12
+ from .tsbuddy import parse_debug_virtual_chassis_topology
13
+ from .tsbuddy import parse_fan
14
+ from .tsbuddy import parse_hardware_info
15
+ from .tsbuddy import parse_health
16
+ from .tsbuddy import parse_health_all_cpu
17
+ from .tsbuddy import parse_interfaces_counters
18
+ from .tsbuddy import parse_interfaces_status
19
+ from .tsbuddy import parse_ip_config
20
+ from .tsbuddy import parse_ip_dos_statistics
21
+ from .tsbuddy import parse_ip_interface
22
+ from .tsbuddy import parse_ip_protocols
23
+ from .tsbuddy import parse_license_info
24
+ from .tsbuddy import parse_lldp_remote_system
25
+ from .tsbuddy import parse_microcode
26
+ from .tsbuddy import parse_module_long
27
+ from .tsbuddy import parse_naas_agent_status
28
+ from .tsbuddy import parse_naas_license
29
+ from .tsbuddy import parse_ntp_keys
30
+ from .tsbuddy import parse_ntp_server_status
31
+ from .tsbuddy import parse_ntp_status
32
+ from .tsbuddy import parse_pkgmgr
33
+ from .tsbuddy import parse_powersupply
34
+ from .tsbuddy import parse_running_directory
35
+ from .tsbuddy import parse_show_cloud_agent_status
36
+ from .tsbuddy import parse_snmp_statistics
37
+ from .tsbuddy import parse_spantree
38
+ from .tsbuddy import parse_spantree_ports_active
39
+ from .tsbuddy import parse_system
40
+ from .tsbuddy import parse_temperature
41
+ from .tsbuddy import parse_transceivers
42
+ from .tsbuddy import parse_virtual_chassis_auto_vf_link_port
43
+ from .tsbuddy import parse_virtual_chassis_chassis_reset_list
44
+ from .tsbuddy import parse_virtual_chassis_consistency
45
+ from .tsbuddy import parse_virtual_chassis_neighbors
46
+ from .tsbuddy import parse_virtual_chassis_slot_reset_list
47
+ from .tsbuddy import parse_virtual_chassis_topology
48
+ from .tsbuddy import parse_virtual_chassis_vf_link
49
+ from .tsbuddy import parse_virtual_chassis_vf_link_member_port
50
+ from .tsbuddy import parse_vlan