1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 """ Script that generate makefile for single archiving configuration. """
21 import os
22
23
24 if not os.environ.has_key('PYTHON_EGG_CACHE') or os.environ['PYTHON_EGG_CACHE'] == None:
25 os.environ['PYTHON_EGG_CACHE'] = os.environ['TEMP'] + "/" + str(os.getpid())
26
27 import configuration
28 import archive
29 import sys
30 from optparse import OptionParser
31
33 """ The application main. """
34 cli = OptionParser(usage="%prog [options]")
35 cli.add_option("--filename", help="Configuration file")
36 cli.add_option("--config", help="Config to load (spec name).")
37 cli.add_option("--id", help="Config number to execute", type="int")
38 cli.add_option("--output", help="Output file")
39 cli.add_option("--writertype", help="Writer Type")
40
41 opts, dummy_args = cli.parse_args()
42 if not opts.filename:
43 cli.print_help()
44 sys.exit(-1)
45 if not opts.config:
46 cli.print_help()
47 sys.exit(-2)
48 if opts.id == None:
49 cli.print_help()
50 sys.exit(-3)
51 if not opts.output:
52 cli.print_help()
53 sys.exit(-4)
54 if not opts.writertype:
55 cli.print_help()
56 sys.exit(-5)
57
58 print "Loading %s..." % opts.filename
59 builder = configuration.NestedConfigurationBuilder(open(opts.filename, 'r'))
60 configset = builder.getConfiguration()
61 print "Getting %s..." % opts.config
62 configs = configset.getConfigurations(opts.config)
63
64 if len(configs) > 0 and int(opts.id) >= 0 and int(opts.id) < len(configs):
65 print "Generating %s.%s as %s..." % (opts.config, opts.id, opts.output)
66 prebuilder = archive.ArchivePreBuilder(configuration.ConfigurationSet(configs), opts.config, opts.writertype, int(opts.id))
67 prebuilder.write(opts.output)
68
69 if __name__ == "__main__":
70 main()
71