Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3370)

Unified Diff: chrome/common/extensions/docs/server2/environment.py

Issue 297963004: Docserver: Update app version parsing since AppEngine started including / (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/environment.py
diff --git a/chrome/common/extensions/docs/server2/environment.py b/chrome/common/extensions/docs/server2/environment.py
index 7433be3ad29b639a5b0257d92e9f831550e509cc..4c8ae583f799fbdf4004dccad6ef32a9f93b4bc4 100644
--- a/chrome/common/extensions/docs/server2/environment.py
+++ b/chrome/common/extensions/docs/server2/environment.py
@@ -2,9 +2,30 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import re
import os
import sys
+from app_yaml_helper import AppYamlHelper
+from third_party.json_schema_compiler.memoize import memoize
+
+
+@memoize
+def GetAppVersion():
+ return GetAppVersionNonMemoized()
+
+
+# This one is for running from tests, which memoization messes up.
+def GetAppVersionNonMemoized():
+ if 'CURRENT_VERSION_ID' in os.environ:
+ # The version ID looks like 2-0-25.36712548 or 2-0-25.23/223; we only
+ # want the 2-0-25.
+ return re.compile('[./]').split(os.environ['CURRENT_VERSION_ID'])[0]
+ # Not running on appengine, get it from the app.yaml file ourselves.
+ app_yaml_path = os.path.join(os.path.split(__file__)[0], 'app.yaml')
+ with open(app_yaml_path, 'r') as app_yaml:
+ return AppYamlHelper.ExtractVersion(app_yaml.read())
+
def _IsServerSoftware(name):
return os.environ.get('SERVER_SOFTWARE', '').find(name) == 0
« no previous file with comments | « chrome/common/extensions/docs/server2/cron_servlet_test.py ('k') | chrome/common/extensions/docs/server2/environment_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698