~oem-qa/checkbox/patch_deselect_ancestors_when_no_child_is_selected

« back to all changes in this revision

Viewing changes to plugins/lock_prompt.py

  • Committer: Marc Tardif
  • Date: 2011-02-09 20:43:07 UTC
  • mto: This revision was merged to the branch mainline in revision 878.
  • Revision ID: marc.tardif@canonical.com-20110209204307-cdv74bu3q2gurymq
Extended lock plugin to stop all events when the file gets deleted and modified the process execute method accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
18
18
#
19
19
import os
 
20
import fcntl
20
21
import posixpath
 
22
import signal
21
23
 
22
24
from time import time
23
25
 
51
53
        directory = posixpath.dirname(self.filename)
52
54
        safe_make_directory(directory)
53
55
 
 
56
        # Try to lock the process
54
57
        self._lock = GlobalLock(self.filename)
55
58
        try:
56
59
            self._lock.acquire()
60
63
                    _("There is another checkbox running. Please close it first."))
61
64
            self._manager.reactor.stop_all()
62
65
 
 
66
        # Stop the process if the lock is deleted
 
67
        def handler(signum, frame):
 
68
            self._manager.reactor.stop_all()
 
69
 
 
70
        signal.signal(signal.SIGIO, handler)
 
71
        fd = os.open(directory,  os.O_RDONLY)
 
72
 
 
73
        fcntl.fcntl(fd, fcntl.F_SETSIG, 0)
 
74
        fcntl.fcntl(fd, fcntl.F_NOTIFY, fcntl.DN_DELETE)
 
75
 
63
76
 
64
77
factory = LockPrompt