Module CreateZipInput |
[hide private]
[frames] | no frames]

# Source Code for Module CreateZipInput

     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  # setting the egg cache directory to a pid specific location.
    23  # this should prevent issues with concurrent threads.
    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
    32 -def main():
    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