4444
4545@app .task ()
4646def setup_cpython_repo ():
47- print ( "Setting up CPython repository" ) # pragma: nocover
47+ logger . info ( "setting up CPython repository" ) # pragma: nocover
4848 if "cpython" not in os .listdir ("." ):
4949 subprocess .check_output (
5050 f"git clone https://{ os .environ .get ('GH_AUTH' )} :x-oauth-basic@github.com/miss-islington/cpython.git" .split ()
@@ -59,9 +59,9 @@ def setup_cpython_repo():
5959 subprocess .check_output (
6060 f"git remote add upstream https://{ os .environ .get ('GH_AUTH' )} :x-oauth-basic@github.com/python/cpython.git" .split ()
6161 )
62- print ( "Finished setting up CPython Repo " )
62+ logger . info ( "finished setting up CPython repository " )
6363 else :
64- print ("cpython directory already exists" )
64+ logger . info ("cpython directory already exists" )
6565
6666
6767@app .task ()
@@ -100,7 +100,16 @@ async def backport_task_asyncio(
100100 if "cpython" in os .listdir ("." ):
101101 os .chdir ("./cpython" )
102102 else :
103- print (f"pwd: { os .getcwd ()} , listdir: { os .listdir ('.' )} " )
103+ logger .warning (
104+ "cpython directory not found" ,
105+ extra = {
106+ "pwd" : os .getcwd (),
107+ "listdir" : os .listdir ("." ),
108+ "branch" : branch ,
109+ "commit_hash" : commit_hash ,
110+ "issue_number" : issue_number ,
111+ },
112+ )
104113
105114 await util .comment_on_pr (
106115 gh ,
@@ -150,7 +159,14 @@ async def backport_task_asyncio(
150159 """ ,
151160 )
152161 await util .assign_pr_to_core_dev (gh , issue_number , merged_by )
153- logger .exception ("InvalidRepoException while backporting to %s" , branch )
162+ logger .exception (
163+ "backport failed: invalid repo state" ,
164+ extra = {
165+ "branch" : branch ,
166+ "commit_hash" : commit_hash ,
167+ "issue_number" : issue_number ,
168+ },
169+ )
154170 except cherry_picker .BranchCheckoutException as bce :
155171 await util .comment_on_pr (
156172 gh ,
@@ -166,7 +182,15 @@ async def backport_task_asyncio(
166182 )
167183 await util .assign_pr_to_core_dev (gh , issue_number , merged_by )
168184 bce_state = cp .get_state_and_verify ()
169- print (bce_state , bce )
185+ logger .exception (
186+ "backport failed: branch checkout error" ,
187+ extra = {
188+ "branch" : branch ,
189+ "commit_hash" : commit_hash ,
190+ "issue_number" : issue_number ,
191+ "state" : bce_state .name ,
192+ },
193+ )
170194 cp .abort_cherry_pick ()
171195 except cherry_picker .CherryPickException as cpe :
172196 await util .comment_on_pr (
@@ -182,7 +206,15 @@ async def backport_task_asyncio(
182206 )
183207 await util .assign_pr_to_core_dev (gh , issue_number , merged_by )
184208 cpe_state = cp .get_state_and_verify ()
185- print (cpe_state , cpe )
209+ logger .exception (
210+ "backport failed: cherry-pick conflict" ,
211+ extra = {
212+ "branch" : branch ,
213+ "commit_hash" : commit_hash ,
214+ "issue_number" : issue_number ,
215+ "state" : cpe_state .name ,
216+ },
217+ )
186218 cp .abort_cherry_pick ()
187219 except cherry_picker .GitHubException as ghe :
188220 await util .comment_on_pr (
@@ -199,7 +231,15 @@ async def backport_task_asyncio(
199231 )
200232 await util .assign_pr_to_core_dev (gh , issue_number , merged_by )
201233 ghe_state = cp .get_state_and_verify ()
202- print (ghe_state , ghe )
234+ logger .exception (
235+ "backport failed: github error" ,
236+ extra = {
237+ "branch" : branch ,
238+ "commit_hash" : commit_hash ,
239+ "issue_number" : issue_number ,
240+ "state" : ghe_state .name ,
241+ },
242+ )
203243 cp .abort_cherry_pick ()
204244
205245
@@ -220,8 +260,14 @@ async def _delete_branch_task_asyncio(branch_name, pr_url, merged, *, installati
220260 if "cpython" in os .listdir ("." ):
221261 os .chdir ("./cpython" )
222262 else :
223- print (f"Cannot delete branch: cpython repo not found. "
224- f"pwd: { os .getcwd ()} , listdir: { os .listdir ('.' )} " )
263+ logger .warning (
264+ "cannot delete branch: cpython repo not found" ,
265+ extra = {
266+ "branch" : branch_name ,
267+ "pwd" : os .getcwd (),
268+ "listdir" : os .listdir ("." ),
269+ },
270+ )
225271 return
226272
227273 if merged :
@@ -249,15 +295,18 @@ def _git_delete_branch(branch_name):
249295 ["git" , "push" , "origin" , "--delete" , branch_name ],
250296 stderr = subprocess .STDOUT
251297 )
252- print ( f"Deleted branch { branch_name } " )
298+ logger . info ( "deleted branch" , extra = { "branch" : branch_name })
253299 except subprocess .CalledProcessError as e :
254- print (f"Failed to delete branch { branch_name } : { e .output .decode ()} " )
300+ logger .exception (
301+ "failed to delete branch" ,
302+ extra = {"branch" : branch_name , "output" : e .output .decode ()},
303+ )
255304 raise
256305
257306
258307class InitRepoStep (bootsteps .StartStopStep ):
259308 def start (self , c ):
260- print ( "Initialize the repository. " )
309+ logger . info ( "initializing the repository" )
261310 setup_cpython_repo ()
262311
263312
0 commit comments