PyBugReporter 1.0.12__tar.gz → 1.0.13__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.
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PKG-INFO +1 -1
- pybugreporter-1.0.13/PyBugReporter/_version.py +1 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter/src/BugReporter.py +74 -23
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter.egg-info/PKG-INFO +1 -1
- pybugreporter-1.0.12/PyBugReporter/_version.py +0 -1
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/LICENSE +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter/__init__.py +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter/py.typed +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter/requirements.txt +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter/src/DiscordBot.py +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter/src/__init__.py +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter/src/py.typed +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter.egg-info/SOURCES.txt +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter.egg-info/dependency_links.txt +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter.egg-info/requires.txt +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/PyBugReporter.egg-info/top_level.txt +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/README.md +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/setup.cfg +0 -0
- {pybugreporter-1.0.12 → pybugreporter-1.0.13}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyBugReporter
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.13
|
|
4
4
|
Summary: A python library for catching thrown exceptions and automatically creating issues on a GitHub repo.
|
|
5
5
|
Home-page: https://github.com/byuawsfhtl/PyBugReporter.git
|
|
6
6
|
Author: Record Linking Lab
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '1.0.13'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import inspect
|
|
2
3
|
import sys
|
|
3
4
|
import traceback
|
|
4
5
|
from functools import wraps
|
|
@@ -93,20 +94,38 @@ class BugReporter:
|
|
|
93
94
|
Args:
|
|
94
95
|
func (callable): the function to be decorated
|
|
95
96
|
"""
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
if inspect.iscoroutinefunction(func):
|
|
98
|
+
@wraps(func)
|
|
99
|
+
async def wrapper_async(*args, **kwargs) -> None:
|
|
100
|
+
"""Wrapper function that catches exceptions and sends a bug report to the github repository.
|
|
101
|
+
Works for async functions.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
*args: the arguments for the function
|
|
105
|
+
**kwargs: the keyword arguments for the function
|
|
106
|
+
"""
|
|
107
|
+
repoName = self.repoName
|
|
108
|
+
try:
|
|
109
|
+
return func(*args, **kwargs)
|
|
110
|
+
except Exception as e:
|
|
111
|
+
await self._handleError_async(e, repoName, *args, **kwargs)
|
|
112
|
+
return wrapper_async
|
|
113
|
+
else:
|
|
114
|
+
@wraps(func)
|
|
115
|
+
def wrapper(*args, **kwargs) -> None:
|
|
116
|
+
"""Wrapper function that catches exceptions and sends a bug report to the github repository.
|
|
117
|
+
Works for synchronous functions.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
*args: the arguments for the function
|
|
121
|
+
**kwargs: the keyword arguments for the function
|
|
122
|
+
"""
|
|
123
|
+
repoName = self.repoName
|
|
124
|
+
try:
|
|
125
|
+
return func(*args, **kwargs)
|
|
126
|
+
except Exception as e:
|
|
127
|
+
self._handleError(e, repoName, *args, **kwargs)
|
|
128
|
+
return wrapper
|
|
110
129
|
|
|
111
130
|
def _handleError(self, e: Exception, repoName: str, *args, **kwargs) -> None:
|
|
112
131
|
"""Handles error by creating a bug report.
|
|
@@ -117,6 +136,46 @@ class BugReporter:
|
|
|
117
136
|
Raises:
|
|
118
137
|
e: the exception that was raised
|
|
119
138
|
"""
|
|
139
|
+
title, description, shortDescription = self._prepare_bug_report(e, repoName, args, kwargs)
|
|
140
|
+
|
|
141
|
+
# Check if we need to send a bug report
|
|
142
|
+
if not self.handlers[repoName].test:
|
|
143
|
+
self._sendBugReport(repoName, title, description, shortDescription)
|
|
144
|
+
|
|
145
|
+
print(title)
|
|
146
|
+
print(description)
|
|
147
|
+
raise e
|
|
148
|
+
|
|
149
|
+
async def _handleError_async(self, e: Exception, repoName: str, *args, **kwargs) -> None:
|
|
150
|
+
"""Handles error by creating a bug report asynchronously.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
e (Exception): the exception that was raised
|
|
154
|
+
|
|
155
|
+
Raises:
|
|
156
|
+
e: the exception that was raised
|
|
157
|
+
"""
|
|
158
|
+
title, description, shortDescription = self._prepare_bug_report(e, repoName, args, kwargs)
|
|
159
|
+
|
|
160
|
+
# Check if we need to send a bug report
|
|
161
|
+
if not self.handlers[repoName].test:
|
|
162
|
+
await self._sendBugReport_async(repoName, title, description, shortDescription)
|
|
163
|
+
|
|
164
|
+
print(title)
|
|
165
|
+
print(description)
|
|
166
|
+
raise e
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _prepare_bug_report(self, e: Exception, repoName: str, *args, **kwargs) -> tuple[str,str,str]:
|
|
170
|
+
"""Prepares all information needed to send the bug report.
|
|
171
|
+
|
|
172
|
+
Args:
|
|
173
|
+
e (Exception): the exception that was raised
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
tuple[str,str,str]: The title, description, and short description of the error for the report.
|
|
177
|
+
|
|
178
|
+
"""
|
|
120
179
|
excType = type(e).__name__
|
|
121
180
|
tb = traceback.extract_tb(sys.exc_info()[2])
|
|
122
181
|
functionName = tb[-1][2]
|
|
@@ -144,15 +203,7 @@ class BugReporter:
|
|
|
144
203
|
shortDescription = f"{start}{compress[:2000 - staticLength]}{end}"
|
|
145
204
|
|
|
146
205
|
print(f"SHORT DESCRIPTION with length {len(shortDescription)}:\n{shortDescription}")
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
# Check if we need to send a bug report
|
|
150
|
-
if not self.handlers[repoName].test:
|
|
151
|
-
self._sendBugReport(repoName, title, description, shortDescription)
|
|
152
|
-
|
|
153
|
-
print(title)
|
|
154
|
-
print(description)
|
|
155
|
-
raise e
|
|
206
|
+
return title,description,shortDescription
|
|
156
207
|
|
|
157
208
|
def _sendBugReport(self, repoName: str, errorTitle: str, errorMessage: str, shortErrorMessage: str) -> None:
|
|
158
209
|
"""Sends a bug report to the Github repository.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyBugReporter
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.13
|
|
4
4
|
Summary: A python library for catching thrown exceptions and automatically creating issues on a GitHub repo.
|
|
5
5
|
Home-page: https://github.com/byuawsfhtl/PyBugReporter.git
|
|
6
6
|
Author: Record Linking Lab
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '1.0.12'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|