Exemple #1
0
 def testGoodYaml(self):
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir,
                    'app.yaml',
                    contents=yaml.dump({'runtime': 'foobar'}))
         runtimes = wrapper_util.GetRuntimes(['app.yaml'])
         self.assertEqual({'foobar'}, runtimes)
Exemple #2
0
 def testYamlNotDict(self):
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir,
                    'app.yaml',
                    contents=yaml.dump(['myfield', 'otherfield']))
         runtimes = wrapper_util.GetRuntimes(['app.yaml'])
         self.assertEqual(set([]), runtimes)
def main():
    """Launches dev_appserver.py."""
    runtimes = wrapper_util.GetRuntimes(sys.argv[1:])
    components = wrapper_util.GetComponents(runtimes)
    options = wrapper_util.ParseDevAppserverFlags(sys.argv[1:])
    if options.support_datastore_emulator:
        components.append('cloud-datastore-emulator')
    update_manager.UpdateManager.EnsureInstalledAndRestart(components,
                                                           command=__file__)

    args = ['--skip_sdk_update_check=True']

    google_analytics_client_id = metrics.GetCIDIfMetricsEnabled()
    google_analytics_user_agent = metrics.GetUserAgentIfMetricsEnabled()
    if google_analytics_client_id:
        args.extend([
            '--google_analytics_client_id={}'.format(
                google_analytics_client_id),
            '--google_analytics_user_agent={}'.format(
                google_analytics_user_agent)
        ])

    # Pass the path to cloud datastore emulator to dev_appserver.
    sdk_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    emulator_dir = os.path.join(sdk_root, 'platform',
                                'cloud-datastore-emulator')
    emulator_script = ('cloud_datastore_emulator.cmd'
                       if platforms.OperatingSystem.IsWindows() else
                       'cloud_datastore_emulator')
    args.append('--datastore_emulator_cmd={}'.format(
        os.path.join(emulator_dir, emulator_script)))

    bootstrapping.ExecutePythonTool(
        os.path.join('platform', 'google_appengine'), 'dev_appserver.py',
        *args)
def main():
  """Launches dev_appserver.py."""
  runtimes = wrapper_util.GetRuntimes(sys.argv[1:])
  components = wrapper_util.GetComponents(runtimes)
  options = wrapper_util.ParseDevAppserverFlags(sys.argv[1:])
  if options.support_datastore_emulator:
    components.append('cloud-datastore-emulator')
  update_manager.UpdateManager.EnsureInstalledAndRestart(
      components,
      command=__file__)

  args = [
      '--skip_sdk_update_check=True'
  ]

  google_analytics_client_id = metrics.GetCIDIfMetricsEnabled()
  google_analytics_user_agent = metrics.GetUserAgentIfMetricsEnabled()
  if google_analytics_client_id:
    args.extend([
        '--google_analytics_client_id={}'.format(google_analytics_client_id),
        '--google_analytics_user_agent={}'.format(google_analytics_user_agent)
    ])

  bootstrapping.ExecutePythonTool(
      os.path.join('platform', 'google_appengine'), 'dev_appserver.py', *args)
Exemple #5
0
def main():
    """Launches dev_appserver.py."""
    runtimes = wrapper_util.GetRuntimes(sys.argv[1:])
    components = wrapper_util.GetComponents(runtimes)
    update_manager.UpdateManager.EnsureInstalledAndRestart(components,
                                                           command=__file__)

    args = [
        '--skip_sdk_update_check=True',
        '--application={}'.format(properties.VALUES.core.project.Get())
    ]

    google_analytics_client_id = metrics.GetCIDIfMetricsEnabled()
    google_analytics_user_agent = metrics.GetUserAgentIfMetricsEnabled()
    if google_analytics_client_id:
        args.extend([
            '--google_analytics_client_id={}'.format(
                google_analytics_client_id),
            '--google_analytics_user_agent={}'.format(
                google_analytics_user_agent)
        ])

    bootstrapping.ExecutePythonTool(
        os.path.join('platform', 'google_appengine'), 'dev_appserver.py',
        *args)
Exemple #6
0
 def testPythonWithoutLibs(self):
     """Python27 without libraries are just python27."""
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir,
                    'app.yaml',
                    contents=yaml.dump({'runtime': 'python27'}))
         runtimes = wrapper_util.GetRuntimes(['app.yaml'])
         self.assertEqual({'python27'}, runtimes)
Exemple #7
0
 def testRuntimeNotString(self):
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir,
                    'app.yaml',
                    contents=yaml.dump({'runtime': {
                        'key': 'value'
                    }}))
         runtimes = wrapper_util.GetRuntimes(['app.yaml'])
         self.assertEqual(set(), runtimes)
Exemple #8
0
 def testValidYamlInDirectory(self):
     dirname = 'app_dir'
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(os.path.join(tmp_dir, dirname),
                    'app.yaml',
                    contents=yaml.dump({'runtime': 'foobar'}),
                    makedirs=True)
         runtimes = wrapper_util.GetRuntimes([dirname])
         self.assertEqual({'foobar'}, runtimes)
Exemple #9
0
 def testMultipleYamlsAndBadArguments(self):
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir,
                    'app.yaml',
                    contents=yaml.dump({'runtime': 'foobar'}))
         self.Touch(tmp_dir,
                    'foo.yaml',
                    contents=yaml.dump({'runtime': 'baz'}))
         runtimes = wrapper_util.GetRuntimes(
             ['foo.yaml', 'app.yaml', '--bad-arg'])
         self.assertEqual({'foobar', 'baz'}, runtimes)
Exemple #10
0
 def testOtherWithLibs(self):
     """Runtime other than python27 with libraries do not yield it."""
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir,
                    'app.yaml',
                    contents=yaml.dump({
                        'runtime': 'foobar',
                        'libraries': 'dummy'
                    }))
         runtimes = wrapper_util.GetRuntimes(['app.yaml'])
         self.assertEqual({'foobar'}, runtimes)
Exemple #11
0
 def testPythonWithLibs(self):
     """Python27 with libraries generate an extra fake runtime."""
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir,
                    'app.yaml',
                    contents=yaml.dump({
                        'runtime': 'python27',
                        'libraries': 'dummy'
                    }))
         runtimes = wrapper_util.GetRuntimes(['app.yaml'])
         self.assertEqual({'python27', 'python27-libs'}, runtimes)
Exemple #12
0
 def testGoodYamlAndBadArguments(self):
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir,
                    'app.yaml',
                    contents=yaml.dump({
                        'runtime': 'foobar',
                        'other_setting': 'othervalue'
                    }))
         runtimes = wrapper_util.GetRuntimes(
             ['lkjfa', 'app.yaml', '--bad-arg'])
         self.assertEqual({'foobar'}, runtimes)
Exemple #13
0
 def testYamlsInCurrentAndSubDirectory(self):
     yaml1_name = 'app.yaml'
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir, yaml1_name, yaml.dump({'runtime': 'foobar1'}))
         dirname = 'modules'
         yaml2_name = os.path.join(dirname, 'app.yaml')
         self.Touch(os.path.join(tmp_dir, dirname),
                    'app.yaml',
                    contents=yaml.dump({'runtime': 'foobar2'}),
                    makedirs=True)
         runtimes = wrapper_util.GetRuntimes([yaml1_name, yaml2_name])
         self.assertEqual({'foobar1', 'foobar2'}, runtimes)
Exemple #14
0
 def testMultipleYamlsInDirectory(self):
     dirname = 'app_dir'
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(os.path.join(tmp_dir, dirname),
                    'app.yaml',
                    contents=yaml.dump({'runtime': 'foobar'}),
                    makedirs=True)
         self.Touch(os.path.join(tmp_dir, dirname),
                    'app.yml',
                    contents=yaml.dump({'runtime': 'foobar'}),
                    makedirs=True)
         with self.assertRaises(wrapper_util.MultipleAppYamlError):
             wrapper_util.GetRuntimes([dirname])
Exemple #15
0
def main():
  """Launches dev_appserver.py."""
  runtimes = wrapper_util.GetRuntimes(sys.argv[1:])
  components = wrapper_util.GetComponents(runtimes)
  update_manager.UpdateManager.EnsureInstalledAndRestart(
      components,
      command=__file__)

  args = [
      '--skip_sdk_update_check=True'
  ]

  bootstrapping.ExecutePythonTool(
      os.path.join('platform', 'google_appengine'), 'dev_appserver.py', *args)
Exemple #16
0
def main():
  """Launches dev_appserver.py."""
  argv = bootstrapping.GetDecodedArgv()
  runtimes = wrapper_util.GetRuntimes(argv[1:])
  options = wrapper_util.ParseDevAppserverFlags(sys.argv[1:])
  if options.support_datastore_emulator:
    java.RequireJavaInstalled(datastore_util.DATASTORE_TITLE, min_version=8)
  components = wrapper_util.GetComponents(runtimes)
  components.append('cloud-datastore-emulator')
  if (platforms.OperatingSystem.Current() == platforms.OperatingSystem.LINUX
      and 'app-engine-php' in components):
    components.remove('app-engine-php')
  update_manager.UpdateManager.EnsureInstalledAndRestart(
      components,
      command=__file__)

  args = [
      '--skip_sdk_update_check=True'
  ]

  google_analytics_client_id = metrics.GetCIDIfMetricsEnabled()
  google_analytics_user_agent = metrics.GetUserAgentIfMetricsEnabled()
  if google_analytics_client_id:
    args.extend([
        '--google_analytics_client_id={}'.format(google_analytics_client_id),
        '--google_analytics_user_agent={}'.format(google_analytics_user_agent)
    ])

  # Pass the path to cloud datastore emulator to dev_appserver.
  # realpath is needed in the case where __file__ is a path containing symlinks.
  sdk_root = os.path.dirname(
      os.path.dirname(os.path.abspath(os.path.realpath(__file__))))
  emulator_dir = os.path.join(sdk_root, 'platform', 'cloud-datastore-emulator')
  emulator_script = (
      'cloud_datastore_emulator.cmd' if platforms.OperatingSystem.IsWindows()
      else 'cloud_datastore_emulator')
  args.append('--datastore_emulator_cmd={}'.format(
      os.path.join(emulator_dir, emulator_script)))

  bootstrapping.ExecutePythonTool(
      os.path.join('platform', 'google_appengine'), 'dev_appserver.py', *args)
Exemple #17
0
 def testBadYaml(self):
     with files.TemporaryDirectory(change_to=True) as tmp_dir:
         self.Touch(tmp_dir, 'app.yaml', contents='!/#{invalidYaml^$/')
         runtimes = wrapper_util.GetRuntimes(['app.yaml'])
         self.assertEqual(set([]), runtimes)
Exemple #18
0
 def testInvalidArgs(self):
     with files.TemporaryDirectory(change_to=True):
         runtimes = wrapper_util.GetRuntimes(
             ['--bad-args', 'foo', 'bar.yaml'])
         self.assertEqual(set([]), runtimes)
Exemple #19
0
 def testEmpty(self):
     self.assertEqual(set([]), wrapper_util.GetRuntimes([]))