#!/usr/bin/env python # # Script to clean up after ccp4mg crash # Reads the process pids from file ~/.CCP4MG/pids # import os import sys import re import signal pid_file = os.path.join (os.environ['HOME'],'.CCP4MG','pids') if not os.path.exists(pid_file): print "No file",pid_file sys.exit() try: f=open(pid_file,'r',1) pid_text=f.readline() f.close() except: print "Error reading file"+pid_file sys.exit() pids = re.split(' ',pid_text) try: os.kill(int(pids[0]),signal.SIGKILL) print "Killed main CCP4mg process" except: print "Could not kill CCP4mg main process" try: os.kill(int(pids[1]),signal.SIGKILL) print "Killed CCP4mg GUI process" except: print "Could not kill CCP4mg GUI process"