PyBugReporter 1.0.13__tar.gz → 1.0.18__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.13 → pybugreporter-1.0.18}/PKG-INFO +1 -1
- pybugreporter-1.0.18/PyBugReporter/_version.py +1 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter/src/BugReporter.py +70 -7
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter/src/DiscordBot.py +5 -2
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter.egg-info/PKG-INFO +1 -1
- pybugreporter-1.0.13/PyBugReporter/_version.py +0 -1
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/LICENSE +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter/__init__.py +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter/py.typed +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter/requirements.txt +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter/src/__init__.py +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter/src/py.typed +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter.egg-info/SOURCES.txt +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter.egg-info/dependency_links.txt +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter.egg-info/requires.txt +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/PyBugReporter.egg-info/top_level.txt +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/README.md +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/setup.cfg +0 -0
- {pybugreporter-1.0.13 → pybugreporter-1.0.18}/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.18
|
|
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.18'
|
|
@@ -7,6 +7,11 @@ from PyBugReporter.src.DiscordBot import DiscordBot
|
|
|
7
7
|
|
|
8
8
|
from python_graphql_client import GraphqlClient
|
|
9
9
|
|
|
10
|
+
BUG_LABEL_NAME: str = "bug"
|
|
11
|
+
AUTO_LABEL_NAME: str = "auto generated"
|
|
12
|
+
BUG_LABEL_COLOR: str = "d73a4a"
|
|
13
|
+
AUTO_LABEL_COLOR: str = "ededed"
|
|
14
|
+
|
|
10
15
|
class NotCreatedError(Exception):
|
|
11
16
|
"""Raised when someone tries to report a bug to a repo that has not been set up as a reporting destination through setVars.
|
|
12
17
|
"""
|
|
@@ -226,8 +231,8 @@ class BugReporter:
|
|
|
226
231
|
|
|
227
232
|
# query variables
|
|
228
233
|
repoId = await self._getRepoId_async(self.handlers[repoName])
|
|
229
|
-
bugLabel =
|
|
230
|
-
autoLabel =
|
|
234
|
+
bugLabel = await self._get_or_create_label_id_async(self.handlers[repoName], repoId, BUG_LABEL_NAME, BUG_LABEL_COLOR)
|
|
235
|
+
autoLabel = await self._get_or_create_label_id_async(self.handlers[repoName], repoId, AUTO_LABEL_NAME, AUTO_LABEL_COLOR)
|
|
231
236
|
|
|
232
237
|
# Create new issue
|
|
233
238
|
createIssue = """
|
|
@@ -264,7 +269,7 @@ class BugReporter:
|
|
|
264
269
|
# Send to Discord if applicable
|
|
265
270
|
if self.handlers[repoName].useDiscord:
|
|
266
271
|
discordBot = DiscordBot(self.handlers[repoName].botToken, self.handlers[repoName].channelId)
|
|
267
|
-
await discordBot.send_message(shortErrorMessage, issueExists)
|
|
272
|
+
await discordBot.send_message(shortErrorMessage, issueExists, errorTitle)
|
|
268
273
|
|
|
269
274
|
if (not issueExists):
|
|
270
275
|
result = await client.execute_async(query=createIssue, variables=variables, headers=headers)
|
|
@@ -344,7 +349,7 @@ class BugReporter:
|
|
|
344
349
|
headers = {"Authorization": f"Bearer {handler.githubKey}"}
|
|
345
350
|
|
|
346
351
|
# query variables
|
|
347
|
-
autoLabel =
|
|
352
|
+
autoLabel = AUTO_LABEL_NAME
|
|
348
353
|
|
|
349
354
|
# Query to return all issues with auto gen label
|
|
350
355
|
findIssue = """
|
|
@@ -413,6 +418,64 @@ class BugReporter:
|
|
|
413
418
|
repoID = await client.execute_async(query=getID, variables=variables, headers=headers)
|
|
414
419
|
return repoID['data']['repository']['id']
|
|
415
420
|
|
|
421
|
+
@classmethod
|
|
422
|
+
async def _get_or_create_label_id_async(cls, handler: BugHandler, repo_id: str, label_name: str, color: str = "ededed") -> str:
|
|
423
|
+
"""Gets a label ID from the repository, creating it if it does not exist.
|
|
424
|
+
|
|
425
|
+
Args:
|
|
426
|
+
handler (BugHandler): the object of reporting details
|
|
427
|
+
repo_id (str): the repository ID
|
|
428
|
+
label_name (str): the name of the label
|
|
429
|
+
color (str): the hex color code for creating the label
|
|
430
|
+
|
|
431
|
+
Returns:
|
|
432
|
+
str: the label ID
|
|
433
|
+
"""
|
|
434
|
+
client = GraphqlClient(endpoint="https://api.github.com/graphql")
|
|
435
|
+
headers = {"Authorization": f"Bearer {handler.githubKey}"}
|
|
436
|
+
|
|
437
|
+
getLabelQuery = """
|
|
438
|
+
query getLabel($owner: String!, $name: String!, $labelName: String!) {
|
|
439
|
+
repository(owner: $owner, name: $name) {
|
|
440
|
+
label(name: $labelName) {
|
|
441
|
+
id
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
"""
|
|
446
|
+
|
|
447
|
+
variables = {
|
|
448
|
+
"owner": handler.orgName,
|
|
449
|
+
"name": handler.repoName,
|
|
450
|
+
"labelName": label_name
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
result = await client.execute_async(query=getLabelQuery, variables=variables, headers=headers)
|
|
454
|
+
labelData = result.get("data", {}).get("repository", {}).get("label")
|
|
455
|
+
if labelData and labelData.get("id"):
|
|
456
|
+
return labelData["id"]
|
|
457
|
+
|
|
458
|
+
createLabelMutation = """
|
|
459
|
+
mutation createLabel($input: CreateLabelInput!) {
|
|
460
|
+
createLabel(input: $input) {
|
|
461
|
+
label {
|
|
462
|
+
id
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
"""
|
|
467
|
+
|
|
468
|
+
createVariables = {
|
|
469
|
+
"input": {
|
|
470
|
+
"repositoryId": repo_id,
|
|
471
|
+
"name": label_name,
|
|
472
|
+
"color": color
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
createResult = await client.execute_async(query=createLabelMutation, variables=createVariables, headers=headers)
|
|
477
|
+
return createResult["data"]["createLabel"]["label"]["id"]
|
|
478
|
+
|
|
416
479
|
@classmethod
|
|
417
480
|
def manualBugReport(cls, repoName: str, errorTitle: str, errorMessage: str) -> None:
|
|
418
481
|
"""Manually sends a bug report to the Github repository.
|
|
@@ -444,8 +507,8 @@ class BugReporter:
|
|
|
444
507
|
|
|
445
508
|
# query variables
|
|
446
509
|
repoId = await cls._getRepoId_async(cls, handler)
|
|
447
|
-
bugLabel =
|
|
448
|
-
autoLabel =
|
|
510
|
+
bugLabel = await cls._get_or_create_label_id_async(handler, repoId, BUG_LABEL_NAME, BUG_LABEL_COLOR)
|
|
511
|
+
autoLabel = await cls._get_or_create_label_id_async(handler, repoId, AUTO_LABEL_NAME, AUTO_LABEL_COLOR)
|
|
449
512
|
|
|
450
513
|
# Create new issue
|
|
451
514
|
createIssue = """
|
|
@@ -481,7 +544,7 @@ class BugReporter:
|
|
|
481
544
|
# Send to Discord if applicable
|
|
482
545
|
if cls.handlers[repoName].useDiscord:
|
|
483
546
|
discordBot = DiscordBot(cls.handlers[repoName].botToken, cls.handlers[repoName].channelId)
|
|
484
|
-
await discordBot.send_message(f"## {repoName}: {errorTitle}\n{errorMessage}", issueExists)
|
|
547
|
+
await discordBot.send_message(f"## {repoName}: {errorTitle}\n{errorMessage}", issueExists, errorTitle)
|
|
485
548
|
|
|
486
549
|
if (issueExists == False):
|
|
487
550
|
result = await client.execute_async(query=createIssue, variables=variables, headers=headers)
|
|
@@ -27,6 +27,7 @@ class DiscordBot(discord.Client):
|
|
|
27
27
|
self.channelId = int(channelId)
|
|
28
28
|
self._message = None
|
|
29
29
|
self._alreadySent = False
|
|
30
|
+
self._title = None
|
|
30
31
|
self._doneFuture = None
|
|
31
32
|
|
|
32
33
|
intents = discord.Intents(emojis = True,
|
|
@@ -36,16 +37,18 @@ class DiscordBot(discord.Client):
|
|
|
36
37
|
guilds = True)
|
|
37
38
|
super().__init__(intents=intents)
|
|
38
39
|
|
|
39
|
-
async def send_message(self, message, alreadySent = False):
|
|
40
|
+
async def send_message(self, message, alreadySent = False, title = None):
|
|
40
41
|
"""
|
|
41
42
|
Sends a message to the specified channel by setting the variables and starting the bot, then turning it off when finished.
|
|
42
43
|
|
|
43
44
|
Args:
|
|
44
45
|
message (str): The message to send.
|
|
45
46
|
alreadySent (bool): Whether the message has already been sent.
|
|
47
|
+
title (str): The stable error title used to find the original message when reacting.
|
|
46
48
|
"""
|
|
47
49
|
self._message = message
|
|
48
50
|
self._alreadySent = alreadySent
|
|
51
|
+
self._title = title
|
|
49
52
|
self._doneFuture = asyncio.get_running_loop().create_future()
|
|
50
53
|
print("Starting bot...")
|
|
51
54
|
# Start the bot as a background task
|
|
@@ -64,7 +67,7 @@ class DiscordBot(discord.Client):
|
|
|
64
67
|
print(f"Sent message to channel {self.channelId}")
|
|
65
68
|
elif channel and self._alreadySent:
|
|
66
69
|
async for message in channel.history(limit=HISTORY_LIMIT):
|
|
67
|
-
if
|
|
70
|
+
if self._title and self._title in message.content:
|
|
68
71
|
await message.add_reaction(EMOJI)
|
|
69
72
|
break
|
|
70
73
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyBugReporter
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.18
|
|
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.13'
|
|
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
|