88"""
99
1010import argparse
11- from concurrent .futures import ThreadPoolExecutor
12- from dataclasses import dataclass
1311import glob
1412import io
1513import json
2018import shutil
2119import subprocess
2220import sys
21+ from concurrent .futures import ThreadPoolExecutor
22+ from dataclasses import dataclass
2323from pathlib import Path
2424from typing import ClassVar , List , Optional
2525
@@ -42,12 +42,8 @@ def exhaust_pipe(handler, pipe):
4242 for line in pipe :
4343 handler (line .rstrip ())
4444
45- executor_out = executor .submit (
46- exhaust_pipe , stdout_handler , process .stdout
47- )
48- executor_err = executor .submit (
49- exhaust_pipe , stderr_handler , process .stderr
50- )
45+ executor_out = executor .submit (exhaust_pipe , stdout_handler , process .stdout )
46+ executor_err = executor .submit (exhaust_pipe , stderr_handler , process .stderr )
5147 executor_out .result ()
5248 executor_err .result ()
5349 retcode = process .poll ()
@@ -203,9 +199,7 @@ def build_id(self, binary):
203199 raise Exception (f"Unreadable build-id for binary { binary } " )
204200 data = json .loads (process .stdout )
205201 if len (data ) != 1 :
206- raise Exception (
207- f"Unreadable output from llvm-readelf for binary { binary } "
208- )
202+ raise Exception (f"Unreadable output from llvm-readelf for binary { binary } " )
209203 notes = data [0 ]["Notes" ]
210204 for note in notes :
211205 note_section = note ["NoteSection" ]
@@ -265,19 +259,10 @@ def write_to_file(self):
265259 def setup_logging (self , log_to_file = False ):
266260 fs = logging .Formatter ("%(asctime)s %(levelname)s:%(name)s:%(message)s" )
267261 if log_to_file :
268- logfile_handler = logging .FileHandler (
269- self .tmp_dir ().joinpath ("log" )
270- )
262+ logfile_handler = logging .FileHandler (self .tmp_dir ().joinpath ("log" ))
271263 logfile_handler .setLevel (logging .DEBUG )
272264 logfile_handler .setFormatter (fs )
273265 logging .getLogger ().addHandler (logfile_handler )
274- stream_handler = logging .StreamHandler (sys .stdout )
275- stream_handler .setFormatter (fs )
276- if self .verbose :
277- stream_handler .setLevel (logging .DEBUG )
278- else :
279- stream_handler .setLevel (logging .INFO )
280- logging .getLogger ().addHandler (stream_handler )
281266 logging .getLogger ().setLevel (logging .DEBUG )
282267
283268 @property
@@ -454,9 +439,7 @@ def start(self):
454439 # Initialize temp directory
455440 os .makedirs (self .tmp_dir (), exist_ok = True )
456441 if len (os .listdir (self .tmp_dir ())) != 0 :
457- raise Exception (
458- f"Temp directory is not clean (in { self .tmp_dir ()} )"
459- )
442+ raise Exception (f"Temp directory is not clean (in { self .tmp_dir ()} )" )
460443 self .setup_logging (log_to_file = True )
461444 os .mkdir (self .output_dir )
462445
@@ -493,9 +476,7 @@ def start(self):
493476 shutil .rmtree (self .local_pb_path , ignore_errors = True )
494477
495478 # Look up the product bundle transfer manifest.
496- self .env_logger .info (
497- "Looking up the product bundle transfer manifest..."
498- )
479+ self .env_logger .info ("Looking up the product bundle transfer manifest..." )
499480 product_name = "minimal." + self .triple_to_arch (self .target )
500481 sdk_version = self .read_sdk_version ()
501482
@@ -517,9 +498,7 @@ def start(self):
517498 )
518499
519500 try :
520- transfer_manifest_url = json .loads (output )[
521- "transfer_manifest_url"
522- ]
501+ transfer_manifest_url = json .loads (output )["transfer_manifest_url" ]
523502 except Exception as e :
524503 print (e )
525504 raise Exception ("Unable to parse transfer manifest" ) from e
@@ -769,9 +748,7 @@ def run(self, args):
769748 # Use /tmp as the test temporary directory
770749 env_vars += '\n "RUST_TEST_TMPDIR=/tmp",'
771750
772- cml .write (
773- self .CML_TEMPLATE .format (env_vars = env_vars , exe_name = exe_name )
774- )
751+ cml .write (self .CML_TEMPLATE .format (env_vars = env_vars , exe_name = exe_name ))
775752
776753 runner_logger .info ("Compiling CML..." )
777754
@@ -922,20 +899,16 @@ def run(self, args):
922899
923900 if stdout_path is not None :
924901 if not os .path .exists (stdout_path ):
925- runner_logger .error (
926- f"stdout file { stdout_path } does not exist."
927- )
902+ runner_logger .error (f"stdout file { stdout_path } does not exist." )
928903 else :
929904 with open (stdout_path , encoding = "utf-8" , errors = "ignore" ) as f :
930- runner_logger . info (f .read ())
905+ sys . stdout . write (f .read ())
931906 if stderr_path is not None :
932907 if not os .path .exists (stderr_path ):
933- runner_logger .error (
934- f"stderr file { stderr_path } does not exist."
935- )
908+ runner_logger .error (f"stderr file { stderr_path } does not exist." )
936909 else :
937910 with open (stderr_path , encoding = "utf-8" , errors = "ignore" ) as f :
938- runner_logger . error (f .read ())
911+ sys . stderr . write (f .read ())
939912
940913 runner_logger .info ("Done!" )
941914 return return_code
@@ -1037,7 +1010,7 @@ def debug(self, args):
10371010 f"--symbol-path={ self .rust_dir } /lib/rustlib/{ self .target } /lib" ,
10381011 ]
10391012
1040- # Add rust source if it's available
1013+ # Add rust source if it's available
10411014 rust_src_map = None
10421015 if args .rust_src is not None :
10431016 # This matches the remapped prefix used by compiletest. There's no
@@ -1210,7 +1183,7 @@ def print_help(args):
12101183 start_parser .add_argument (
12111184 "--use-local-product-bundle-if-exists" ,
12121185 help = "if the product bundle already exists in the local path, use "
1213- "it instead of downloading it again" ,
1186+ "it instead of downloading it again" ,
12141187 action = "store_true" ,
12151188 )
12161189 start_parser .set_defaults (func = start )
@@ -1246,9 +1219,7 @@ def print_help(args):
12461219 )
12471220 cleanup_parser .set_defaults (func = cleanup )
12481221
1249- syslog_parser = subparsers .add_parser (
1250- "syslog" , help = "prints the device syslog"
1251- )
1222+ syslog_parser = subparsers .add_parser ("syslog" , help = "prints the device syslog" )
12521223 syslog_parser .set_defaults (func = syslog )
12531224
12541225 debug_parser = subparsers .add_parser (
0 commit comments