11from __future__ import division , print_function , unicode_literals
22
33import asyncio
4- import asyncio .subprocess
54import configparser
6- import contextlib
75import datetime
86import filecmp
97import itertools as it
108import logging
11- import multiprocessing as mp
129import os
1310import shutil
1411import zipfile
2320import rcc .util
2421from rcc .model import Commit , TestCase , TestCaseResult
2522
26- from .languages import language_from_extension
27-
2823DEFAULT_MKDIR_PERMISSIONS = 0o777
2924
3025
@@ -302,11 +297,11 @@ def is_correct(test_result):
302297def cleanup_tests (base_dir ):
303298 if os .path .isdir (base_dir ):
304299
305- def rmtree_handler (func , path , exc_info ):
300+ def rmtree_handler (_func , _path , exc_info ):
306301 exc_type , exc_value , _ = exc_info
307302 raise exc_type (exc_value )
308303
309- shutil .rmtree (base_dir , onerror = rmtree_handler )
304+ shutil .rmtree (base_dir , onexc = rmtree_handler )
310305
311306
312307def process_commit (data_provider , commit ):
@@ -321,22 +316,22 @@ def process_commit(data_provider, commit):
321316
322317 try :
323318 storage_provider = rcc .provider .storage .from_config (cfg )
324- except :
319+ except Exception :
325320 logger .error ("[{c.id}] Storage provider error" .format (c = commit ), exc_info = True )
326321 commit .status = Commit .STATUS_INTERNAL_ERROR
327322 data_provider .update_commit (commit )
328323 return
329324
330325 try :
331326 test_cases = data_provider .fetch_test_cases (commit )
332- except :
327+ except Exception :
333328 logger .error (
334329 "[{c.id}] Failed to fetch test cases" .format (c = commit ), exc_info = True
335330 )
336331 commit .status = Commit .STATUS_INTERNAL_ERROR
337332 data_provider .update_commit (commit )
338333 if cfg .cleanup_on_error :
339- cleanup_tests (base_dir )
334+ cleanup_tests (os . path . join ( cfg . exec_dir , "commit_{}" . format ( commit . id )) )
340335 return
341336
342337 # Delete results already produced by this commit, if any
@@ -355,7 +350,7 @@ def process_commit(data_provider, commit):
355350 create_container_cfg_file (commit , test_cases , base_dir )
356351 copy_source_files (data_provider , storage_provider , commit , base_dir )
357352 copy_test_case_files (storage_provider , test_cases , base_dir )
358- except :
353+ except Exception :
359354 logger .error ("[{c.id}] Failed to prepare runs" .format (c = commit ), exc_info = True )
360355 commit .status = Commit .STATUS_INTERNAL_ERROR
361356 data_provider .update_commit (commit )
@@ -368,7 +363,7 @@ def process_commit(data_provider, commit):
368363 test_results = run_tests (
369364 data_provider , storage_provider , commit , test_cases , base_dir , remote_dir
370365 )
371- except :
366+ except Exception :
372367 logger .error ("[{c.id}] Failed to run tests" .format (c = commit ), exc_info = True )
373368 commit .status = Commit .STATUS_INTERNAL_ERROR
374369 data_provider .update_commit (commit )
@@ -386,7 +381,7 @@ def process_commit(data_provider, commit):
386381 output_fname = prepare_output_file (commit , base_dir )
387382 storage_provider .store_commit_output (commit , output_fname )
388383 cleanup_tests (base_dir )
389- except :
384+ except Exception :
390385 logger .error (
391386 "[{c.id}] Could not save results, commit data might be inconsistent" .format (
392387 c = commit
0 commit comments