587
|
1 |
#============================================================================
|
|
2 |
#Name : CreateZipInput.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
|
19 |
|
|
20 |
""" Script that generate makefile for single archiving configuration. """
|
|
21 |
import os
|
|
22 |
import tempfile
|
|
23 |
# setting the egg cache directory to a pid specific location.
|
|
24 |
# this should prevent issues with concurrent threads.
|
|
25 |
if not os.environ.has_key('PYTHON_EGG_CACHE') or os.environ['PYTHON_EGG_CACHE'] == None:
|
|
26 |
os.environ['PYTHON_EGG_CACHE'] = tempfile.gettempdir() + "/" + str(os.getpid())
|
|
27 |
|
|
28 |
import configuration
|
|
29 |
import archive
|
|
30 |
import logging
|
|
31 |
import sys
|
|
32 |
from optparse import OptionParser
|
|
33 |
|
|
34 |
_logger = logging.getLogger('CreateZipInput')
|
|
35 |
_logger.setLevel(logging.INFO)
|
|
36 |
|
|
37 |
def main():
|
|
38 |
""" The application main. """
|
|
39 |
cli = OptionParser(usage="%prog [options]")
|
|
40 |
cli.add_option("--filename", help="Configuration file")
|
|
41 |
cli.add_option("--config", help="Config to load (spec name).")
|
|
42 |
cli.add_option("--id", help="Config number to execute", type="int")
|
|
43 |
cli.add_option("--output", help="Output file")
|
|
44 |
cli.add_option("--writertype", help="Writer Type")
|
|
45 |
|
|
46 |
opts, dummy_args = cli.parse_args()
|
|
47 |
if not opts.filename:
|
|
48 |
cli.print_help()
|
|
49 |
sys.exit(-1)
|
|
50 |
if not opts.config:
|
|
51 |
cli.print_help()
|
|
52 |
sys.exit(-2)
|
|
53 |
if opts.id == None:
|
|
54 |
cli.print_help()
|
|
55 |
sys.exit(-3)
|
|
56 |
if not opts.output:
|
|
57 |
cli.print_help()
|
|
58 |
sys.exit(-4)
|
|
59 |
if not opts.writertype:
|
|
60 |
cli.print_help()
|
|
61 |
sys.exit(-5)
|
|
62 |
|
|
63 |
_logger.info("Loading %s..." % opts.filename)
|
|
64 |
builder = configuration.NestedConfigurationBuilder(open(opts.filename, 'r'))
|
|
65 |
configset = builder.getConfiguration()
|
|
66 |
_logger.info("Getting %s..." % opts.config)
|
|
67 |
configs = configset.getConfigurations(opts.config)
|
|
68 |
|
|
69 |
if len(configs) > 0 and int(opts.id) >= 0 and int(opts.id) < len(configs):
|
|
70 |
_logger.info("Generating %s.%s as %s..." % (opts.config, opts.id, opts.output))
|
|
71 |
prebuilder = archive.ArchivePreBuilder(configuration.ConfigurationSet(configs), opts.config, opts.writertype, int(opts.id))
|
|
72 |
prebuilder.write(opts.output)
|
|
73 |
|
|
74 |
if __name__ == "__main__":
|
|
75 |
main() |