@@ -165,7 +165,8 @@ def shprint(command, *args, **kwargs):
165165
166166 # If logging is not in DEBUG mode, trim the command if necessary
167167 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 ))
169170 else :
170171 logger .debug ('{}{}' .format (string , Err_Style .RESET_ALL ))
171172
@@ -176,36 +177,54 @@ def shprint(command, *args, **kwargs):
176177 output = command (* args , ** kwargs )
177178 for line in output :
178179 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 ()
180184 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 ))
183188 sys .stdout .flush ()
184189 need_closing_newline = True
185190 else :
186191 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 )))
190199 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 ):
192202 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 )]
195207 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 ))
197210 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 ))
199214 printtail (err .stdout , 'STDOUT' , Fore .YELLOW , tail_n ,
200215 re .compile (filter_in ) if filter_in else None ,
201216 re .compile (filter_out ) if filter_out else None )
202217 printtail (err .stderr , 'STDERR' , Fore .RED )
203218 if is_critical :
204219 env = kwargs .get ("env" )
205220 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 ))
209228 exit (1 )
210229 else :
211230 raise
@@ -1611,21 +1630,6 @@ def apply_patch(self, filename, arch='armeabi'):
16111630 shprint (sh .patch , "-t" , "-d" , self .get_build_dir (arch ), "-p1" ,
16121631 "-i" , filename , _tail = 10 )
16131632
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-
16291633 def copy_file (self , filename , dest ):
16301634 info ("Copy {} to {}" .format (filename , dest ))
16311635 filename = join (self .recipe_dir , filename )
0 commit comments