#! /usr/bin/env python3
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
try:
with open(filedict, 'rb') as fpid:
process_ids=pickle.load(fpid)
- except:
+ except Exception:
process_ids=[]
pass
# check if PID is already in dictionary
if verbose(): print("addToKillList: %s : %s" % ( str(command_pid), command ))
process_ids.append({int(command_pid): [command]})
dir = os.path.dirname(filedict)
- if not os.path.exists(dir): os.makedirs(dir, 0o777)
+ if not os.path.exists(dir):
+ from salome_utils import makeDir
+ makeDir(dir)
with open(filedict,'wb') as fpid:
pickle.dump(process_ids, fpid)
- except:
+ except Exception:
if verbose(): print("addToKillList: can not add command %s : %s to the kill list" % ( str(command_pid), command ))
pass
pass
try:
with open(filedict, 'rb') as fpid:
process_ids=pickle.load(fpid)
- except:
+ except Exception:
process_ids=[]
pass
# kill processes
for pid, cmd in list(process_id.items()):
try:
os.kill(int(pid),signal.SIGKILL)
- except:
+ except Exception:
print(" ------------------ process %s : %s inexistant"% (pid, cmd[0]))
pass
pass
pass
# remove processes dictionary file
- os.remove(filedict)
+ if os.path.exists(filedict):
+ os.remove(filedict)
pass
if __name__ == "__main__":