diff --git a/PyBugReporter/_version.py b/PyBugReporter/_version.py index 36f0696..85fb3bc 100644 --- a/PyBugReporter/_version.py +++ b/PyBugReporter/_version.py @@ -1 +1 @@ -__version__ = '1.0.10' \ No newline at end of file +__version__ = '1.0.10b0.dev2' \ No newline at end of file diff --git a/PyBugReporter/src/BugReporter.py b/PyBugReporter/src/BugReporter.py index e1ac717..231dbe1 100644 --- a/PyBugReporter/src/BugReporter.py +++ b/PyBugReporter/src/BugReporter.py @@ -366,6 +366,17 @@ async def _getRepoId_async(self, handler: BugHandler) -> str: def manualBugReport(cls, repoName: str, errorTitle: str, errorMessage: str) -> None: """Manually sends a bug report to the Github repository. + Args: + repoName (str): the name of the repo to report to + errorTitle (str): the title of the error + errorMessage (str): the error message + """ + asyncio.run(cls.manualBugReportAsync(repoName,errorTitle,errorMessage)) + + @classmethod + async def manualBugReportAsync(cls, repoName: str, errorTitle: str, errorMessage: str) -> None: + """Manually sends a bug report to the Github repository. + Args: repoName (str): the name of the repo to report to errorTitle (str): the title of the error @@ -381,7 +392,7 @@ def manualBugReport(cls, repoName: str, errorTitle: str, errorMessage: str) -> N headers = {"Authorization": f"Bearer {handler.githubKey}"} # query variables - repoId = cls._getRepoId(cls, handler) + repoId = await cls._getRepoId_async(cls, handler) bugLabel = "LA_kwDOJ3JPj88AAAABU1q15w" autoLabel = "LA_kwDOJ3JPj88AAAABU1q2DA" @@ -414,10 +425,15 @@ def manualBugReport(cls, repoName: str, errorTitle: str, errorMessage: str) -> N } } - issueExists = cls._checkIfIssueExists(cls, handler, errorTitle) + issueExists = await cls._checkIfIssueExists_async(cls, handler, errorTitle) + + # Send to Discord if applicable + if cls.handlers[repoName].useDiscord: + discordBot = DiscordBot(cls.handlers[repoName].botToken, cls.handlers[repoName].channelId) + await discordBot.send_message(f"## {repoName}: {errorTitle}\n{errorMessage}", issueExists) if (issueExists == False): - result = asyncio.run(client.execute_async(query=createIssue, variables=variables, headers=headers)) + result = await client.execute_async(query=createIssue, variables=variables, headers=headers) print('\nThis error has been reported to the Tree Growth team.\n') else: print('\nOur team is already aware of this issue.\n') diff --git a/test.py b/test.py index 009d8a2..342c90e 100644 --- a/test.py +++ b/test.py @@ -16,6 +16,10 @@ BugReporter.setVars(token, 'PyBugReporter', 'byuawsfhtl', False, True, discordToken, channelId) + BugReporter.manualBugReport("PyBugReporter", + "Testing manual bug report", + "This is a test of the manual bug report functionality") + @BugReporter('PyBugReporter', extraInfo=True, env='test') def test(item, item2=None): # raise Exception(""" @@ -53,43 +57,45 @@ def test(item, item2=None): # really really really really really really really really long test exception # """) - def this(): - def exception(): - def has(): - def an(): - def insane(): - def traceback(): - def length(): - def that(): - def just(): - def keeps(): - def going(): - def on(): - def yep(): - def still(): - def more(): - def never(): - def do(): - def this(): - raise Exception("This is a test exception") - this() - do() - never() - more() - still() - yep() - on() - going() - keeps() - just() - that() - length() - traceback() - insane() - an() - has() - exception() - this() + # def this(): + # def exception(): + # def has(): + # def an(): + # def insane(): + # def traceback(): + # def length(): + # def that(): + # def just(): + # def keeps(): + # def going(): + # def on(): + # def yep(): + # def still(): + # def more(): + # def never(): + # def do(): + # def this(): + # raise Exception("This is a test exception") + # this() + # do() + # never() + # more() + # still() + # yep() + # on() + # going() + # keeps() + # just() + # that() + # length() + # traceback() + # insane() + # an() + # has() + # exception() + # this() + + raise Exception("This is a test exception") - test(None, item2='item2') \ No newline at end of file + # test(None, item2='item2') \ No newline at end of file