File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -91,20 +91,29 @@ def _file_unchanged(old, new):
91
91
92
92
def shell_out (cmd , shell = False , logfile = None ):
93
93
logging .debug ("Running command %r" , cmd )
94
+ now = str (datetime .now ())
94
95
try :
95
96
output = subprocess .check_output (cmd , shell = shell ,
96
97
stdin = subprocess .PIPE ,
97
98
stderr = subprocess .STDOUT ,
98
99
universal_newlines = True )
99
100
if logfile :
100
101
with open (logfile , 'a+' ) as log :
101
- log .write ("#" + str (datetime .now ()) + "\n " )
102
+ log .write ("# " + now + "\n " )
103
+ log .write (f"# Command { cmd !r} ran successfully:" )
102
104
log .write (output )
103
105
log .write ("\n \n " )
104
106
return output
105
107
except subprocess .CalledProcessError as e :
106
- logging .debug ("Command failed with output %r" , e .output )
107
- raise
108
+ if logfile :
109
+ with open (logfile , 'a+' ) as log :
110
+ log .write ("# " + now + "\n " )
111
+ log .write (f"# Command { cmd !r} failed:" )
112
+ log .write (output )
113
+ log .write ("\n \n " )
114
+ logging .error ("Command failed (see %s at %s)" , logfile , now )
115
+ else :
116
+ logging .error ("Command failed with output %r" , e .output )
108
117
109
118
110
119
def changed_files (directory , other ):
You can’t perform that action at this time.
0 commit comments