1
# Gufw 10.04.1 - http://gufw.tuxfamily.org
2
# Copyright (C) 2009 Raul Soriano & Marcos Alvarez Costales
4
# Gufw is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
9
# Gufw is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with Gufw; if not, see http://www.gnu.org/licenses for more
22
from model.Variable import Variable
28
# Check if gufw is root application
36
dlg = gtk.MessageDialog(None, buttons=gtk.BUTTONS_CLOSE, message_format=variable.get_text("018"))
42
# This class manages application instances
45
#specify the file where the pid is stores (pid file)
47
self.pid_file = variable.get_path("pid_file")
49
self.startApplication()
51
#check wether the app is running
53
#check wether the pid file exists
54
if not os.path.isfile(self.pid_file):
57
#read the pid from file
60
file = open(self.pid_file, 'rt')
67
#check wether the proccess specified exists
71
os.kill(pid, 0) #this raises an exception if the pid is invalid
76
exit(0) # exit reaises an exception, so there is no need for a try/except block
78
#called when there is no running instances, storing the new pid (creating a instance)
79
def startApplication(self):
80
file = open(self.pid_file, 'wt')
81
file.write( str(os.getpid()))
84
#called when the running insnstance exits, removing the existing pid file (destroying the existing instance)
85
def exitApplication(self):
86
# Close WindowsxitApplication(self):
88
os.remove(self.pid_file)