@@ -59,24 +59,36 @@ def print_buildbot_info(utility_name):
5959
6060 print ()
6161
62- str_git = os .popen ("git log -n 1 --decorate=full" ).read ()
62+ try :
63+ r_log = subprocess .run (
64+ ["git" , "log" , "-n" , "1" , "--decorate=full" ],
65+ capture_output = True ,
66+ text = True ,
67+ )
68+ if r_log .returncode != 0 :
69+ raise RuntimeError ("git log failed" )
6370
64- git_hash = str_git .split ()[1 ]
65- git_head = str_git [str_git .find ("HEAD -> " ) + 8 : str_git .find (")" )]
71+ str_git = r_log .stdout
72+ git_hash = str_git .split ()[1 ]
73+ git_head = str_git [str_git .find ("HEAD -> " ) + 8 : str_git .find (")" )]
6674
67- git_head = git_head .split ("," )
75+ git_head = git_head .split ("," )
6876
69- if len (git_head ) == 1 :
70- git_head = "\033 [1;92m" + git_head [0 ] + "\033 [0;0m"
71- else :
72- git_head = "\033 [1;92m" + git_head [0 ] + "\033 [0;0m , \033 [1;91m" + git_head [0 ] + "\033 [0;0m"
77+ if len (git_head ) == 1 :
78+ git_head = "\033 [1;92m" + git_head [0 ] + "\033 [0;0m"
79+ else :
80+ git_head = (
81+ "\033 [1;92m" + git_head [0 ] + "\033 [0;0m , \033 [1;91m" + git_head [0 ] + "\033 [0;0m"
82+ )
7383
74- print ("\033 [1;34mGit status \033 [0;0m: " )
75- print (" \033 [1;93mcommit \033 [0;0m: " , git_hash )
76- print (" \033 [1;36mHEAD \033 [0;0m: " , git_head )
77- print (" \033 [1;31mmodified files\033 [0;0m (since last commit):" )
78- print (os .popen ('git diff-index --name-only HEAD -- | sed "s/^/ /g"' ).read ())
79- print ("\033 [1;90m" + "-" * col_cnt + "\033 [0;0m\n " )
84+ print ("\033 [1;34mGit status \033 [0;0m: " )
85+ print (" \033 [1;93mcommit \033 [0;0m: " , git_hash )
86+ print (" \033 [1;36mHEAD \033 [0;0m: " , git_head )
87+ print (" \033 [1;31mmodified files\033 [0;0m (since last commit):" )
88+ print (os .popen ('git diff-index --name-only HEAD -- | sed "s/^/ /g"' ).read ())
89+ print ("\033 [1;90m" + "-" * col_cnt + "\033 [0;0m\n " )
90+ except Exception : # noqa: BLE001
91+ print ("Warn : couldn't get git status" )
8092
8193
8294def run_cmd (str ):
0 commit comments