scripts/export_image.py
author Todd Larsen <tlarsen@google.com>
Wed, 20 Aug 2008 00:18:56 +0000
changeset 92 296e0d824407
parent 50 43df6d7be888
permissions -rwxr-xr-x
Create package for up-coming Role views.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
#
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
#
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""Script to export a Google App Engine "image" of a Melange application.
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
For details:
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
  trunk/scripts/export_image.py --help
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
Default values for flags can be specified in valid Python syntax in the
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
~/.soc_scripts_settings file.  See settings.py for details.
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
"""
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
__authors__ = [
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
  # alphabetical order by last name, please
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
  '"Todd Larsen" <tlarsen@google.com>',
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
]
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
import os
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
import sys
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
import pysvn
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
from trunk.scripts import app_image
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
from trunk.scripts import settings
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
from trunk.scripts import svn_helper
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    40
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
50
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
    42
def buildOptionList(defaults={}):
46
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
  """Returns a list of command-line settings.Options for this script.
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    45
  Args:
50
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
    46
    defaults: dict of possible pre-loaded default values; default is empty
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
    47
      dict (which is safe because it is not altered)
46
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    48
  """
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
  def_repo = defaults.get('repo')
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    50
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    51
  if def_repo:
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    52
    repo_help_msg = 'SVN repository; default is %s' % def_repo
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    53
  else:
50
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
    54
    repo_help_msg = 'SVN repository; REQUIRED if a default is missing'
46
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    55
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    56
  return [
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    57
      settings.Option(
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    58
          '-R', '--repo', action='store', dest='repo',
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    59
          default=def_repo, help=repo_help_msg),
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
      settings.Option(
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    61
          '-s', '--src', action='store', dest='src', required=True,
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    62
          help='(REQUIRED) name of source app in /trunk/apps/ to export'),
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    63
      settings.Option(
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    64
          '-i', '--image', action='store', dest='image', required=True,
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    65
          help='(REQUIRED) exported image destination'),
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    66
      settings.Option(
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    67
          '-r', '--rev', type='int', action='store', dest='rev',
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    68
          default=None, help='optional revision number on which to export'),
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    69
  ]
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    70
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
def main(args):
50
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
    73
  # create parser just for usage info before settings file is read successfully
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
    74
  usage_parser = settings.OptionParser(option_list=buildOptionList())
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
    75
46
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    76
  # attempt to read the common trunk/scripts settings file
50
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
    77
  defaults = settings.readPythonSettingsOrDie(parser=usage_parser)
46
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    78
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    79
  # create the command-line options parser
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    80
  parser = settings.makeOptionParserOrDie(
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    81
      option_list=buildOptionList(defaults))
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    82
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    83
  # parse the command-line options
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    84
  options, args = settings.parseOptionsOrDie(parser, args)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    85
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    86
  # ensure that various paths end with the / separator
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    87
  src, image, repo = svn_helper.formatDirPaths(
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    88
      options.src, options.image, options.repo)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    89
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    90
  # expand and make "OS-agnostic" the proposed App Engine image path
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    91
  # (which is why no working copy path is needed or supplied)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    92
  image = svn_helper.getExpandedWorkingCopyPath(image)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    93
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    94
  setup_errors = []
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    95
50
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
    96
  if os.path.exists(image):
46
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    97
    setup_errors.extend(
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    98
        ['--image destination directory must not already exist:',
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    99
         '  %s' % image])
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   100
50
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
   101
  # dirname() called twice because image always ends with os.sep as a result
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
   102
  # of svn_helper.getExpandedWorkingCopyPath()
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
   103
  parent_dir = os.path.dirname(os.path.dirname(image))
43df6d7be888 Changes to address Sverre's comments about the previous commit.
Todd Larsen <tlarsen@google.com>
parents: 46
diff changeset
   104
46
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   105
  if not os.path.isdir(parent_dir):
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   106
    try:
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   107
      os.makedirs(parent_dir)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   108
      print 'Created --image parent directory:\n %s\n' % parent_dir
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   109
    except (IOError, OSError), fs_err:
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   110
      setup_errors.extend(
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   111
          ['--image parent directory could not be created:',
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   112
           '  %s' % parent_dir,
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   113
           '  %s: %s' % (fs_err.__class__.__name__,
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   114
                       ' '.join([str(arg) for arg in fs_err.args]))])
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   115
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   116
  if not options.repo:
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   117
    setup_errors.extend(
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   118
        ['--repo must be supplied or have a settings file default'])
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   119
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   120
  if setup_errors:
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   121
    return settings.printErrorsAndUsage(setup_errors, parser)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   122
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   123
  def callbackGetLogMessage():
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   124
    return True, 'trunk/apps/%s application exported to %s' % (src, image)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   125
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   126
  client = svn_helper.getPySvnClient()
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   127
  # this should never actually be called, but just in case...
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   128
  client.callback_get_log_message = callbackGetLogMessage
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   129
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   130
  # export trunk/apps/<src> first, so image root directory will exist
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   131
  app_image.exportFromSrcApp(src, repo, image, rev=options.rev)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   132
  app_image.exportFromThirdParty(repo, image, rev=options.rev)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   133
  app_image.exportFromFramework(repo, image, rev=options.rev)
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   134
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   135
  return 0
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   136
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   137
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   138
if __name__ == '__main__':
0fb942ba3046 Script to 'svn export' /trunk/apps/<app>, /thirdparty/, /trunk/soc/ to local
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   139
  sys.exit(main(sys.argv))