@@ -171,13 +171,16 @@ def create_github_issue(err_msg, exc_msg):
171171
172172 key = hashlib .md5 (_ ).hexdigest ()[:8 ]
173173
174- bug_report = "Bug Report: Unhandled exception \" " + str ([i for i in exc_msg .split (settings .END_LINE .LF ) if i ][- 1 ]) + "\" " + "(#" + key + ")"
174+ bug_report = (
175+ "Bug Report: Unhandled exception \" "
176+ + str ([i for i in exc_msg .split (settings .END_LINE .LF ) if i ][- 1 ])
177+ + "\" (#" + key + ")"
178+ )
175179
176180 while True :
177181 try :
178- message = "Do you want to automatically create a new (anonymized) issue "
179- message += "with the unhandled exception information at "
180- message += "the official Github repository? [y/N] "
182+ message = "Do you want to prepare a sanitized GitHub issue report "
183+ message += "for manual submission? [y/N] "
181184 choise = read_input (message , default = "N" , check_batch = True )
182185 if choise in settings .CHOICE_YES :
183186 break
@@ -186,51 +189,66 @@ def create_github_issue(err_msg, exc_msg):
186189 return
187190 else :
188191 invalid_option (choise )
189- pass
190192 except :
191193 settings .print_data_to_stdout ("" )
192194 raise SystemExit ()
193195
194196 err_msg = err_msg [err_msg .find (settings .END_LINE .LF ):]
195- request = _urllib .request .Request (url = "https://api.github.com/search/issues?q=" + \
196- _urllib .parse .quote ("repo:commixproject/commix" + settings .SINGLE_WHITESPACE + str (bug_report ))
197- )
197+
198+ request = _urllib .request .Request (
199+ url = "https://api.github.com/search/issues?q=" +
200+ _urllib .parse .quote (
201+ "repo:commixproject/commix" +
202+ settings .SINGLE_WHITESPACE +
203+ str (bug_report )
204+ )
205+ )
198206
199207 try :
200- content = _urllib .request .urlopen (request , timeout = settings .TIMEOUT ).read ()
208+ content = _urllib .request .urlopen (
209+ request ,
210+ timeout = settings .TIMEOUT
211+ ).read ()
201212 _ = json .loads (content )
202213 duplicate = _ ["total_count" ] > 0
203214 closed = duplicate and _ ["items" ][0 ]["state" ] == "closed"
204215 if duplicate :
205216 warn_msg = "That issue seems to be already reported"
206217 if closed :
207- warn_msg += " and resolved. Please update to the latest "
208- warn_msg += "(dev) version from official GitHub repository at '" + settings .GIT_URL + "'"
218+ warn_msg += " and resolved. Please update to the latest "
219+ warn_msg += "(dev) version from official GitHub repository at '"
220+ warn_msg += settings .GIT_URL + "'"
209221 warn_msg += "." + settings .END_LINE .LF
210- settings .print_data_to_stdout (settings .print_warning_msg (warn_msg ))
222+ settings .print_data_to_stdout (
223+ settings .print_warning_msg (warn_msg )
224+ )
211225 return
212226 except :
213227 pass
214228
215- data = {"title" : str (bug_report ), "body" : "```" + str (err_msg ) + settings .END_LINE .LF + "```" + settings .END_LINE .LF + "```" + str (exc_msg ) + "```" }
216- request = _urllib .request .Request (url = "https://api.github.com/repos/commixproject/commix/issues" ,
217- data = json .dumps (data ).encode (),
218- headers = {settings .AUTHORIZATION : "token " + base64 .b64decode (settings .GITHUB_REPORT_OAUTH_TOKEN .encode (settings .DEFAULT_CODEC )).decode ()}
219- )
220- try :
221- content = _urllib .request .urlopen (request , timeout = settings .TIMEOUT ).read ()
222- except Exception as err :
223- content = None
224-
225- issue_url = re .search (r"https://github.com/commixproject/commix/issues/\d+" , content .decode (settings .DEFAULT_CODEC ) or "" )
226- if issue_url :
227- info_msg = "The created Github issue can been found at the address '" + str (issue_url .group (0 )) + "'." + settings .END_LINE .LF
228- settings .print_data_to_stdout (settings .print_info_msg (info_msg ))
229- else :
230- warn_msg = "Something went wrong while creating a Github issue."
231- if settings .UNAUTHORIZED_ERROR in str (err ):
232- warn_msg += " Please update to the latest revision." + settings .END_LINE .LF
233- settings .print_data_to_stdout (settings .print_warning_msg (warn_msg ))
229+ params = {
230+ "title" : str (bug_report ),
231+ "body" :
232+ "```" + str (err_msg ) + settings .END_LINE .LF +
233+ "```" + settings .END_LINE .LF +
234+ "```" + str (exc_msg ) + "```"
235+ }
236+
237+ issue_url = (
238+ "https://github.com/commixproject/commix/issues/new?"
239+ + _urllib .parse .urlencode (params )
240+ )
241+
242+ info_msg = (
243+ "A sanitized GitHub issue has been prepared with " +
244+ "relevant error details for manual review and submission:" +
245+ settings .END_LINE .LF +
246+ issue_url
247+ )
248+
249+ settings .print_data_to_stdout (
250+ settings .print_info_msg (info_msg )
251+ )
234252
235253"""
236254Masks sensitive data in the supplied message.
0 commit comments