Use /usr/bin/env to locate python.
[bitbake.git] / bin / oemaked
1 #!/usr/bin/env python
2
3 import os, sys, stat
4 from daemon import daemonize
5 from time import sleep
6
7 if not os.environ.has_key("OEFILES"):
8         sys.exit(1)
9
10 olddir=os.getcwd()
11 delay=30
12
13 files = []
14 for file in os.environ["OEFILES"].split():
15         file = os.path.abspath(file)
16         if os.access(file, os.R_OK):
17                 print "%s" % file
18                 files.append([file, None])
19
20 daemonize("/home/kergoth/out", "/home/kergoth/err", "/dev/null")
21
22 os.chdir(olddir)
23
24 def runOEMake():
25         os.system("oemake")
26
27 while 1:
28         __dirty = 0
29         for file in files:
30                 time = os.stat(file[0])[stat.ST_MTIME]
31                 if file[1] is None or time != file[1]:
32                         __dirty = 1
33                         file[1] = time
34         if __dirty == 1:
35                 runOEMake()
36
37         sleep(delay)