1#!/usr/bin/python
2# Copyright 2015 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import subprocess
7import sys
8
9from catapult_build import module_finder
10from catapult_build import temp_deployment_dir
11
12
13def DevAppserver(paths, args):
14  """Starts a dev server for an App Engine app.
15
16  Args:
17    paths: List of paths to files and directories that should be linked
18        (or copied) in the deployment directory.
19    args: List of additional arguments to pass to the dev server.
20  """
21  try:
22    import dev_appserver  # pylint: disable=unused-variable
23  except ImportError:
24    # TODO(qyearsley): Put the App Engine SDK in the path with the
25    # binary dependency manager.
26    # See https://github.com/catapult-project/catapult/issues/2135
27    print 'This script requires the App Engine SDK to be in PYTHONPATH.'
28    sys.exit(1)
29  with temp_deployment_dir.TempDeploymentDir(paths) as temp_dir:
30    print 'Running dev server on "%s".' % temp_dir
31    subprocess.call(
32        [module_finder.FindModule('dev_appserver')] + args + [temp_dir]
33    )
34