@@ -110,10 +110,10 @@ def get_compilation_failure(messages):
110
110
continue
111
111
112
112
if msg_type == 'error' or msg_type == 'tool_error' :
113
- logging .error (message )
113
+ rel_log .error (message )
114
114
return "Error"
115
115
else :
116
- logging .debug (message )
116
+ rel_log .debug (message )
117
117
118
118
return "Internal"
119
119
@@ -134,26 +134,26 @@ def invoke_api(payload, url, auth, polls, begin="start/"):
134
134
"""
135
135
136
136
# send task to api
137
- logging .debug (url + begin + "| data: " + str (payload ))
137
+ rel_log .debug (url + begin + "| data: " + str (payload ))
138
138
r = requests .post (url + begin , data = payload , auth = auth )
139
- logging .debug (r .request .body )
139
+ rel_log .debug (r .request .body )
140
140
141
141
if r .status_code != 200 :
142
- logging .error ("HTTP code %d reported." , r .status_code )
142
+ rel_log .error ("HTTP code %d reported." , r .status_code )
143
143
return False , "Internal"
144
144
145
145
response = r .json ()
146
- logging .debug (response )
146
+ rel_log .debug (response )
147
147
uuid = response ['result' ]['data' ]['task_id' ]
148
- logging .debug ("Task accepted and given ID: %s" , uuid )
148
+ rel_log .debug ("Task accepted and given ID: %s" , uuid )
149
149
result = False
150
150
fail_type = None
151
151
152
152
# It currently seems to take the onlide IDE API ~30s to process the compile
153
153
# request and provide a response. Set the poll time to half that in case it
154
154
# does manage to compile quicker.
155
155
poll_delay = 15
156
- logging .debug ("Running with a poll for response delay of: %ss" , poll_delay )
156
+ rel_log .debug ("Running with a poll for response delay of: %ss" , poll_delay )
157
157
158
158
# poll for output
159
159
for check in range (polls ):
@@ -169,15 +169,15 @@ def invoke_api(payload, url, auth, polls, begin="start/"):
169
169
# 3) Internal failure of the online compiler
170
170
result = bool (data ['compilation_success' ])
171
171
if result :
172
- logging .info ("\t \t Compilation SUCCESSFUL\n " )
172
+ rel_log .info ("COMPILATION SUCCESSFUL\n " )
173
173
else :
174
174
# Did this fail due to a genuine compilation error or a failue of
175
175
# the api itself ?
176
- logging .info ("\t \t Compilation FAILURE\n " )
176
+ rel_log .info ("COMPILATION FAILURE\n " )
177
177
fail_type = get_compilation_failure (data ['new_messages' ])
178
178
break
179
179
else :
180
- logging .info ("\t \t Compilation FAILURE\n " )
180
+ rel_log .info ("COMPILATION FAILURE\n " )
181
181
182
182
if not result and fail_type == None :
183
183
fail_type = "Internal"
@@ -219,11 +219,11 @@ def run_cmd(command, exit_on_failure=False):
219
219
Returns:
220
220
result - True/False indicating the success/failure of the command
221
221
"""
222
- logging .debug ('[Exec] %s' , ' ' .join (command ))
222
+ rel_log .debug ('[Exec] %s' , ' ' .join (command ))
223
223
return_code = subprocess .call (command , shell = True )
224
224
225
225
if return_code :
226
- logging .warning ("The command '%s' failed with return code: %s" ,
226
+ rel_log .warning ("The command '%s' failed with return code: %s" ,
227
227
(' ' .join (command ), return_code ))
228
228
if exit_on_failure :
229
229
sys .exit (1 )
@@ -245,13 +245,13 @@ def run_cmd_with_output(command, exit_on_failure=False):
245
245
result - True/False indicating the success/failure of the command
246
246
output - The output of the command if it was successful, else empty string
247
247
"""
248
- logging .debug ('[Exec] %s' , ' ' .join (command ))
248
+ rel_log .debug ('[Exec] %s' , ' ' .join (command ))
249
249
returncode = 0
250
250
output = ""
251
251
try :
252
252
output = subprocess .check_output (command , shell = True )
253
253
except subprocess .CalledProcessError as e :
254
- logging .warning ("The command '%s' failed with return code: %s" ,
254
+ rel_log .warning ("The command '%s' failed with return code: %s" ,
255
255
(' ' .join (command ), e .returncode ))
256
256
returncode = e .returncode
257
257
if exit_on_failure :
@@ -273,15 +273,15 @@ def upgrade_test_repo(test, user, library, ref, repo_path):
273
273
Returns:
274
274
updated - True if library was updated, False otherwise
275
275
"""
276
- logging .info ("Updating test repo: '%s' to SHA: %s" , test , ref )
276
+ rel_log .info ("Updating test repo: '%s' to SHA: %s" , test , ref )
277
277
cwd = os .getcwd ()
278
278
279
279
repo = "https://" + user + '@developer.mbed.org/users/' + user + '/code/' + test
280
280
281
281
# Clone the repo if it doesn't already exist
282
282
path = abspath (repo_path + '/' + test )
283
283
if not os .path .exists (path ):
284
- logging .info ("Test repo doesn't exist, cloning..." )
284
+ rel_log .info ("Test repo doesn't exist, cloning..." )
285
285
os .chdir (abspath (repo_path ))
286
286
clone_cmd = ['hg' , 'clone' , repo ]
287
287
run_cmd (clone_cmd , exit_on_failure = True )
@@ -300,7 +300,7 @@ def upgrade_test_repo(test, user, library, ref, repo_path):
300
300
301
301
os .rename (lib_file , bak_file )
302
302
else :
303
- logging .error ("!! Failure to backup lib file prior to updating." )
303
+ rel_log .error ("Failure to backup lib file prior to updating." )
304
304
return False
305
305
306
306
# mbed 2 style lib file contains one line with the following format
@@ -338,7 +338,7 @@ def upgrade_test_repo(test, user, library, ref, repo_path):
338
338
run_cmd (cmd , exit_on_failure = True )
339
339
340
340
except :
341
- logging .info ("Lib file already up to date and thus nothing to commit" )
341
+ rel_log .info ("Lib file already up to date and thus nothing to commit" )
342
342
343
343
os .chdir (cwd )
344
344
return updated
@@ -395,12 +395,11 @@ def get_latest_library_versions(repo_path):
395
395
return mbed , mbed_dev
396
396
397
397
def log_results (lst , title ):
398
- logging .info (title )
399
398
if len (lst ) == 0 :
400
- logging .info ("\t None \n " )
399
+ rel_log .info ("%s - None" , title )
401
400
else :
402
401
for entry in lst :
403
- logging .info ("\t Test : %s, Target: %s\n " , entry [0 ], entry [1 ])
402
+ rel_log .info ("%s - Test : %s, Target: %s" , title , entry [0 ], entry [1 ])
404
403
405
404
406
405
if __name__ == '__main__' :
@@ -417,11 +416,12 @@ def log_results(lst, title):
417
416
418
417
# Set logging level
419
418
logging .basicConfig (level = level )
419
+ rel_log = logging .getLogger ("check-release" )
420
420
421
421
# Read configuration data
422
- json_data = json . load ( open (os .path .join (os .path .dirname (__file__ ),
423
- "check_release. json" )) )
424
-
422
+ with open (os .path .join (os .path .dirname (__file__ ), "check_release.json" )) as config :
423
+ json_data = json . load ( config )
424
+
425
425
supported_targets = []
426
426
427
427
if len (json_data ["target_list" ]) > 0 :
@@ -452,11 +452,11 @@ def log_results(lst, title):
452
452
mbed , mbed_dev = get_latest_library_versions (repo_path )
453
453
454
454
if not mbed or not mbed_dev :
455
- logging .error ("Could not obtain latest versions of library files!!" )
455
+ rel_log .error ("Could not obtain latest versions of library files!!" )
456
456
exit (1 )
457
457
458
- logging .info ("Latest mbed lib version = %s" , mbed )
459
- logging .info ("Latest mbed-dev lib version = %s" , mbed_dev )
458
+ rel_log .info ("Latest mbed lib version = %s" , mbed )
459
+ rel_log .info ("Latest mbed-dev lib version = %s" , mbed_dev )
460
460
461
461
# First update test repos to latest versions of their embedded libraries
462
462
for test in test_list :
@@ -473,10 +473,10 @@ def log_results(lst, title):
473
473
474
474
# Compile each test for each supported target
475
475
for test in tests :
476
- logging .info ("Test compiling program : %s\n " , test )
476
+ rel_log .info ("COMPILING PROGRAM : %s\n " , test )
477
477
for target in supported_targets :
478
478
for retry in range (0 , retries ):
479
- logging .info ("\t Compiling target : %s , attempt %u\n " , target , retry )
479
+ rel_log .info ("COMPILING TARGET : %s , attempt %u\n " , target , retry )
480
480
result , mesg = build_repo (target , test , user , password )
481
481
if not result :
482
482
if mesg == 'Internal' :
@@ -490,19 +490,19 @@ def log_results(lst, title):
490
490
passes += (int )(result )
491
491
break
492
492
else :
493
- logging .error ("\t \t Compilation failed due to internal errors.\n " )
494
- logging .error ("\t \t Skipping test/target combination!\n " )
493
+ rel_log .error ("Compilation failed due to internal errors.\n " )
494
+ rel_log .error ("Skipping test/target combination!\n " )
495
495
total -= 1
496
496
skipped .append ([test , target ])
497
497
498
- logging .info (" SUMMARY OF COMPILATION RESULTS" )
499
- logging .info (" ------------------------------\n " )
500
- logging .info (" NUMBER OF TEST APPS: %d, NUMBER OF TARGETS: %d\n " ,
498
+ rel_log .info (" SUMMARY OF COMPILATION RESULTS" )
499
+ rel_log .info (" ------------------------------" )
500
+ rel_log .info (" NUMBER OF TEST APPS: %d, NUMBER OF TARGETS: %d\n " ,
501
501
len (tests ), len (supported_targets ))
502
- log_results (failures , " FAILURES: \n " )
503
- log_results (skipped , " SKIPPED: \n " )
502
+ log_results (failures , " FAILED " )
503
+ log_results (skipped , " SKIPPED" )
504
504
505
505
# Output a % pass rate, indicate a failure if not 100% successful
506
506
pass_rate = (float (passes ) / float (total )) * 100.0
507
- logging .info (" PASS RATE %.1f %%\n " , pass_rate )
507
+ rel_log .info (" PASS RATE %.1f %%\n " , pass_rate )
508
508
sys .exit (not (pass_rate == 100 ))
0 commit comments