~ubuntu-branches/ubuntu/jaunty/debomatic/jaunty

« back to all changes in this revision

Viewing changes to Debomatic/launcher.py

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2009-02-01 15:38:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090201153835-maad8eyhjexymepu
Tags: 0.6-1
* New upstream release.
* Adjust copyright holders.
* Remove all patches (implemented upstream), as well as quilt support.
* Add DM-Upload-Allowed field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Deb-o-Matic
2
 
#
3
 
# Copyright (C) 2007-2008 Luca Falavigna
4
 
#
5
 
# Author: Luca Falavigna <dktrkranz@ubuntu.com>
6
 
#
7
 
# This program is free software; you can redistribute it and/or modify
8
 
# it under the terms of the GNU General Public License as published by
9
 
# the Free Software Foundation; version 3 of the License.
10
 
#
11
 
# This program is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program; if not, write to the Free Software
18
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
 
 
20
 
import threading
21
 
from time import sleep
22
 
from Debomatic import globals
23
 
from Debomatic import build
24
 
 
25
 
try:
26
 
    import os
27
 
    from re import findall
28
 
    from pyinotify import WatchManager, Notifier, EventsCodes, ProcessEvent
29
 
 
30
 
    class PE(ProcessEvent):
31
 
        def process_IN_CLOSE_WRITE(self, event):
32
 
            if findall('source.changes$', event.name):
33
 
                threading.Thread(None, build.build_process).start()
34
 
 
35
 
    def launcher_inotify():
36
 
        if globals.Options.getint('default', 'inotify'):
37
 
            wm = WatchManager()
38
 
            notifier = Notifier(wm, PE())
39
 
            wm.add_watch(globals.Options.get('default', 'packagedir'), EventsCodes.IN_CLOSE_WRITE, rec=True)
40
 
            while True:
41
 
                try:
42
 
                    notifier.process_events()
43
 
                    if notifier.check_events():
44
 
                        notifier.read_events()
45
 
                except KeyboardInterrupt:
46
 
                    notifier.stop()
47
 
                    break
48
 
except:
49
 
    def launcher_inotify():
50
 
        pass
51
 
 
52
 
def launcher_timer():
53
 
    while 1:
54
 
        threading.Thread(None, build.build_process).start()
55
 
        sleep(globals.Options.getint('default', 'sleep'))
56
 
 
57
 
def launcher():
58
 
    threading.Thread(None, launcher_inotify).start()
59
 
    threading.Thread(None, launcher_timer).start()
60