@@ -373,9 +373,10 @@ def __del__(self):
373
373
self ._omc_log_file .close ()
374
374
try :
375
375
self ._omc_process .wait (timeout = 2.0 )
376
- except Exception :
376
+ except subprocess . TimeoutExpired :
377
377
if self ._omc_process :
378
- logger .warning ("OMC did not exit after being sent the quit() command; killing the process with pid=%s" , self ._omc_process .pid )
378
+ logger .warning ("OMC did not exit after being sent the quit() command; "
379
+ "killing the process with pid=%s" , self ._omc_process .pid )
379
380
self ._omc_process .kill ()
380
381
self ._omc_process .wait ()
381
382
@@ -405,14 +406,14 @@ def _start_omc_process(self, timeout):
405
406
try :
406
407
with open (self ._dockerCidFile , "r" ) as fin :
407
408
self ._dockerCid = fin .read ().strip ()
408
- except Exception :
409
+ except IOError :
409
410
pass
410
411
if self ._dockerCid :
411
412
break
412
413
time .sleep (timeout / 40.0 )
413
414
try :
414
415
os .remove (self ._dockerCidFile )
415
- except Exception :
416
+ except FileNotFoundError :
416
417
pass
417
418
if self ._dockerCid is None :
418
419
logger .error ("Docker did not start. Log-file says:\n %s" % (open (self ._omc_log_file .name ).read ()))
@@ -520,9 +521,10 @@ def _connect_to_omc(self, timeout):
520
521
while True :
521
522
if self ._dockerCid :
522
523
try :
523
- self ._port = subprocess .check_output (["docker" , "exec" , self ._dockerCid , "cat" , self ._port_file ], stderr = subprocess .DEVNULL ).decode ().strip ()
524
+ self ._port = subprocess .check_output (["docker" , "exec" , self ._dockerCid , "cat" , self ._port_file ],
525
+ stderr = subprocess .DEVNULL ).decode ().strip ()
524
526
break
525
- except Exception :
527
+ except subprocess . CalledProcessError :
526
528
pass
527
529
else :
528
530
if os .path .isfile (self ._port_file ):
0 commit comments