@@ -165,7 +165,8 @@ def shprint(command, *args, **kwargs):
165
165
166
166
# If logging is not in DEBUG mode, trim the command if necessary
167
167
if logger .level > logging .DEBUG :
168
- logger .info ('{}{}' .format (shorten_string (string , columns - 12 ), Err_Style .RESET_ALL ))
168
+ logger .info ('{}{}' .format (shorten_string (string , columns - 12 ),
169
+ Err_Style .RESET_ALL ))
169
170
else :
170
171
logger .debug ('{}{}' .format (string , Err_Style .RESET_ALL ))
171
172
@@ -176,36 +177,54 @@ def shprint(command, *args, **kwargs):
176
177
output = command (* args , ** kwargs )
177
178
for line in output :
178
179
if logger .level > logging .DEBUG :
179
- msg = line .replace ('\n ' , ' ' ).replace ('\t ' , ' ' ).replace ('\b ' , ' ' ).rstrip ()
180
+ msg = line .replace (
181
+ '\n ' , ' ' ).replace (
182
+ '\t ' , ' ' ).replace (
183
+ '\b ' , ' ' ).rstrip ()
180
184
if msg :
181
- # if len(msg) > msg_width: msg = msg[:(msg_width - 3)] + '...'
182
- sys .stdout .write ('{}\r {}{:<{width}}' .format (Err_Style .RESET_ALL , msg_hdr , shorten_string (msg , msg_width ), width = msg_width ))
185
+ sys .stdout .write ('{}\r {}{:<{width}}' .format (
186
+ Err_Style .RESET_ALL , msg_hdr ,
187
+ shorten_string (msg , msg_width ), width = msg_width ))
183
188
sys .stdout .flush ()
184
189
need_closing_newline = True
185
190
else :
186
191
logger .debug ('' .join (['\t ' , line .rstrip ()]))
187
- if need_closing_newline : sys .stdout .write ('{}\r {:>{width}}\r ' .format (Style .RESET_ALL , ' ' , width = (columns - 1 )))
188
- except sh .ErrorReturnCode , err :
189
- if need_closing_newline : sys .stdout .write ('{}\r {:>{width}}\r ' .format (Style .RESET_ALL , ' ' , width = (columns - 1 )))
192
+ if need_closing_newline :
193
+ sys .stdout .write ('{}\r {:>{width}}\r ' .format (
194
+ Style .RESET_ALL , ' ' , width = (columns - 1 )))
195
+ except sh .ErrorReturnCode as err :
196
+ if need_closing_newline :
197
+ sys .stdout .write ('{}\r {:>{width}}\r ' .format (
198
+ Style .RESET_ALL , ' ' , width = (columns - 1 )))
190
199
if tail_n or filter_in or filter_out :
191
- def printtail (out , name , forecolor , tail_n = 0 , re_filter_in = None , re_filter_out = None ):
200
+ def printtail (out , name , forecolor , tail_n = 0 ,
201
+ re_filter_in = None , re_filter_out = None ):
192
202
lines = out .splitlines ()
193
- if re_filter_in is not None : lines = [l for l in lines if re_filter_in .search (l )]
194
- if re_filter_out is not None : lines = [l for l in lines if not re_filter_out .search (l )]
203
+ if re_filter_in is not None :
204
+ lines = [l for l in lines if re_filter_in .search (l )]
205
+ if re_filter_out is not None :
206
+ lines = [l for l in lines if not re_filter_out .search (l )]
195
207
if tail_n == 0 or len (lines ) <= tail_n :
196
- info ('{}:\n {}\t {}{}' .format (name , forecolor , '\t \n ' .join (lines ), Fore .RESET ))
208
+ info ('{}:\n {}\t {}{}' .format (
209
+ name , forecolor , '\t \n ' .join (lines ), Fore .RESET ))
197
210
else :
198
- info ('{} (last {} lines of {}):\n {}\t {}{}' .format (name , tail_n , len (lines ), forecolor , '\t \n ' .join (lines [- tail_n :]), Fore .RESET ))
211
+ info ('{} (last {} lines of {}):\n {}\t {}{}' .format (
212
+ name , tail_n , len (lines ),
213
+ forecolor , '\t \n ' .join (lines [- tail_n :]), Fore .RESET ))
199
214
printtail (err .stdout , 'STDOUT' , Fore .YELLOW , tail_n ,
200
215
re .compile (filter_in ) if filter_in else None ,
201
216
re .compile (filter_out ) if filter_out else None )
202
217
printtail (err .stderr , 'STDERR' , Fore .RED )
203
218
if is_critical :
204
219
env = kwargs .get ("env" )
205
220
if env is not None :
206
- info ("{}ENV:{}\n {}\n " .format (Fore .YELLOW , Fore .RESET , "\n " .join ("set {}={}" .format (n ,v ) for n ,v in env .items ())))
207
- info ("{}COMMAND:{}\n cd {} && {} {}\n " .format (Fore .YELLOW , Fore .RESET , getcwd (), command , ' ' .join (args )))
208
- warning ("{}ERROR: {} failed!{}" .format (Fore .RED , command , Fore .RESET ))
221
+ info ("{}ENV:{}\n {}\n " .format (
222
+ Fore .YELLOW , Fore .RESET , "\n " .join (
223
+ "set {}={}" .format (n ,v ) for n ,v in env .items ())))
224
+ info ("{}COMMAND:{}\n cd {} && {} {}\n " .format (
225
+ Fore .YELLOW , Fore .RESET , getcwd (), command , ' ' .join (args )))
226
+ warning ("{}ERROR: {} failed!{}" .format (
227
+ Fore .RED , command , Fore .RESET ))
209
228
exit (1 )
210
229
else :
211
230
raise
@@ -1611,21 +1630,6 @@ def apply_patch(self, filename, arch='armeabi'):
1611
1630
shprint (sh .patch , "-t" , "-d" , self .get_build_dir (arch ), "-p1" ,
1612
1631
"-i" , filename , _tail = 10 )
1613
1632
1614
- def apply_all_patches (self , wildcard = join ('patches' ,'*.patch' ), arch = 'armeabi' ):
1615
- patches = glob .glob (join (self .recipe_dir , wildcard ))
1616
- if not patches :
1617
- warning ('requested patches {} not found for {}' .format (wildcard , self .name ))
1618
- for filename in sorted (patches ):
1619
- name = splitext (basename (filename ))[0 ]
1620
- patched_flag = join (self .get_build_container_dir (arch ), name + '.patched' )
1621
- if exists (patched_flag ):
1622
- info ('patch {} already applied to {}, skipping' .format (name , self .name ))
1623
- else :
1624
- self .apply_patch (filename , arch = arch )
1625
- sh .touch (patched_flag )
1626
- return len (patches )
1627
-
1628
-
1629
1633
def copy_file (self , filename , dest ):
1630
1634
info ("Copy {} to {}" .format (filename , dest ))
1631
1635
filename = join (self .recipe_dir , filename )
0 commit comments