| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 | 6 |
| 7 from google.appengine.api import app_identity |
| 7 from google.appengine.api import modules | 8 from google.appengine.api import modules |
| 8 | 9 |
| 9 | 10 |
| 10 def IsInDevServer(): # pragma: no cover. | 11 def IsInDevServer(): # pragma: no cover. |
| 11 """Returns whether the code runs in dev server locally.""" | 12 """Returns whether the code runs in dev server locally.""" |
| 12 return os.environ['APPLICATION_ID'].startswith('dev') | 13 return os.environ['APPLICATION_ID'].startswith('dev') |
| 13 | 14 |
| 14 | 15 |
| 15 def GetCurrentVersion(): # pragma: no cover. | 16 def GetCurrentVersion(): # pragma: no cover. |
| 16 """Returns the version of this module.""" | 17 """Returns the version of this module.""" |
| 17 return modules.get_current_version_name() | 18 return modules.get_current_version_name() |
| 18 | 19 |
| 19 | 20 |
| 21 def GetDefaultVersionHostname(): # pragma: no cover. |
| 22 """Returns the default version hostname of this service.""" |
| 23 return app_identity.get_default_version_hostname() |
| 24 |
| 25 |
| 20 def GetTargetNameForModule(module_name, version=None): # pragma: no cover. | 26 def GetTargetNameForModule(module_name, version=None): # pragma: no cover. |
| 21 """Returns the target name for the given module and version. | 27 """Returns the target name for the given module and version. |
| 22 | 28 |
| 23 Version defaults to the one running this code. | 29 Version defaults to the one running this code. |
| 24 """ | 30 """ |
| 25 if IsInDevServer(): | 31 if IsInDevServer(): |
| 26 # Dev server doesn't support multiple versions of a module. | 32 # Dev server doesn't support multiple versions of a module. |
| 27 return module_name | 33 return module_name |
| 28 else: | 34 else: |
| 29 version = version or GetCurrentVersion() | 35 version = version or GetCurrentVersion() |
| 30 return '%s.%s' % (version, module_name) | 36 return '%s.%s' % (version, module_name) |
| 31 | 37 |
| OLD | NEW |