8
8
"""
9
9
10
10
import argparse
11
- from concurrent .futures import ThreadPoolExecutor
12
- from dataclasses import dataclass
13
11
import glob
14
12
import io
15
13
import json
20
18
import shutil
21
19
import subprocess
22
20
import sys
21
+ from concurrent .futures import ThreadPoolExecutor
22
+ from dataclasses import dataclass
23
23
from pathlib import Path
24
24
from typing import ClassVar , List , Optional
25
25
@@ -42,12 +42,8 @@ def exhaust_pipe(handler, pipe):
42
42
for line in pipe :
43
43
handler (line .rstrip ())
44
44
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 )
51
47
executor_out .result ()
52
48
executor_err .result ()
53
49
retcode = process .poll ()
@@ -203,9 +199,7 @@ def build_id(self, binary):
203
199
raise Exception (f"Unreadable build-id for binary { binary } " )
204
200
data = json .loads (process .stdout )
205
201
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 } " )
209
203
notes = data [0 ]["Notes" ]
210
204
for note in notes :
211
205
note_section = note ["NoteSection" ]
@@ -265,19 +259,10 @@ def write_to_file(self):
265
259
def setup_logging (self , log_to_file = False ):
266
260
fs = logging .Formatter ("%(asctime)s %(levelname)s:%(name)s:%(message)s" )
267
261
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" ))
271
263
logfile_handler .setLevel (logging .DEBUG )
272
264
logfile_handler .setFormatter (fs )
273
265
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 )
281
266
logging .getLogger ().setLevel (logging .DEBUG )
282
267
283
268
@property
@@ -454,9 +439,7 @@ def start(self):
454
439
# Initialize temp directory
455
440
os .makedirs (self .tmp_dir (), exist_ok = True )
456
441
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 ()} )" )
460
443
self .setup_logging (log_to_file = True )
461
444
os .mkdir (self .output_dir )
462
445
@@ -493,9 +476,7 @@ def start(self):
493
476
shutil .rmtree (self .local_pb_path , ignore_errors = True )
494
477
495
478
# 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..." )
499
480
product_name = "minimal." + self .triple_to_arch (self .target )
500
481
sdk_version = self .read_sdk_version ()
501
482
@@ -517,9 +498,7 @@ def start(self):
517
498
)
518
499
519
500
try :
520
- transfer_manifest_url = json .loads (output )[
521
- "transfer_manifest_url"
522
- ]
501
+ transfer_manifest_url = json .loads (output )["transfer_manifest_url" ]
523
502
except Exception as e :
524
503
print (e )
525
504
raise Exception ("Unable to parse transfer manifest" ) from e
@@ -769,9 +748,7 @@ def run(self, args):
769
748
# Use /tmp as the test temporary directory
770
749
env_vars += '\n "RUST_TEST_TMPDIR=/tmp",'
771
750
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 ))
775
752
776
753
runner_logger .info ("Compiling CML..." )
777
754
@@ -922,20 +899,16 @@ def run(self, args):
922
899
923
900
if stdout_path is not None :
924
901
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." )
928
903
else :
929
904
with open (stdout_path , encoding = "utf-8" , errors = "ignore" ) as f :
930
- runner_logger . info (f .read ())
905
+ sys . stdout . write (f .read ())
931
906
if stderr_path is not None :
932
907
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." )
936
909
else :
937
910
with open (stderr_path , encoding = "utf-8" , errors = "ignore" ) as f :
938
- runner_logger . error (f .read ())
911
+ sys . stderr . write (f .read ())
939
912
940
913
runner_logger .info ("Done!" )
941
914
return return_code
@@ -1037,7 +1010,7 @@ def debug(self, args):
1037
1010
f"--symbol-path={ self .rust_dir } /lib/rustlib/{ self .target } /lib" ,
1038
1011
]
1039
1012
1040
- # Add rust source if it's available
1013
+ # Add rust source if it's available
1041
1014
rust_src_map = None
1042
1015
if args .rust_src is not None :
1043
1016
# This matches the remapped prefix used by compiletest. There's no
@@ -1210,7 +1183,7 @@ def print_help(args):
1210
1183
start_parser .add_argument (
1211
1184
"--use-local-product-bundle-if-exists" ,
1212
1185
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" ,
1214
1187
action = "store_true" ,
1215
1188
)
1216
1189
start_parser .set_defaults (func = start )
@@ -1246,9 +1219,7 @@ def print_help(args):
1246
1219
)
1247
1220
cleanup_parser .set_defaults (func = cleanup )
1248
1221
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" )
1252
1223
syslog_parser .set_defaults (func = syslog )
1253
1224
1254
1225
debug_parser = subparsers .add_parser (
0 commit comments