forked from cmdln/flashbake
/
flashbakeall
executable file
·52 lines (33 loc) · 1.47 KB
/
flashbakeall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
# wrapper script for calling 'flashbake' on all projects under a given path
import sys, logging
from optparse import OptionParser
import os
import os.path
import subprocess
import fnmatch
VERSION='0.23'
pattern = '.flashbake'
def locate_projects(root):
for path, dirs, files in os.walk(root):
for project_path in [os.path.normpath(path) for filename in files if fnmatch.fnmatch(filename, pattern)]:
yield project_path
if __name__ == "__main__":
usage = "usage: %prog [options] <search_root> [quiet_min]"
parser = OptionParser(usage=usage, version='%s %s' % ('%prog', VERSION))
parser.add_option('-o','--options', dest='flashbake_options', default='',
action='store', type='string', metavar='FLASHBAKE_OPTS',
help="options to pass through to the 'flashbake' command. Use quotes to pass multiple arguments.")
(options, args) = parser.parse_args()
if len(args) < 1:
parser.error('Must specify root search directory.')
sys.exit(1)
LAUNCH_DIR = os.path.abspath(sys.path[0])
flashbake_cmd = os.path.join(LAUNCH_DIR, "flashbake")
flashbake_opts = options.flashbake_options.split()
for project in locate_projects(args[0]):
print(project + ":")
proc = [ flashbake_cmd ] + flashbake_opts + [project]
if len(args) > 1:
proc.append(args[1])
subprocess.call(proc)