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

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

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better redirects Created 7 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/cron_servlet.py
diff --git a/chrome/common/extensions/docs/server2/cron_servlet.py b/chrome/common/extensions/docs/server2/cron_servlet.py
index 5929ac9e5d924c62820b67bbd70e39453b709153..86bcfb82371882b6cc6b7490f1880611fea8a5c6 100644
--- a/chrome/common/extensions/docs/server2/cron_servlet.py
+++ b/chrome/common/extensions/docs/server2/cron_servlet.py
@@ -9,7 +9,6 @@ import traceback
from app_yaml_helper import AppYamlHelper
from appengine_wrappers import (
GetAppVersion, DeadlineExceededError, IsDevServer, logservice)
-from branch_utility import BranchUtility
from caching_file_system import CachingFileSystem
from compiled_file_system import CompiledFileSystem
from empty_dir_file_system import EmptyDirFileSystem
@@ -26,7 +25,7 @@ class _SingletonRenderServletDelegate(RenderServlet.Delegate):
def __init__(self, server_instance):
self._server_instance = server_instance
- def CreateServerInstanceForChannel(self, channel):
+ def CreateServerInstance(self):
return self._server_instance
class CronServlet(Servlet):
@@ -34,17 +33,13 @@ class CronServlet(Servlet):
'''
def __init__(self, request, delegate_for_test=None):
Servlet.__init__(self, request)
- self._channel = request.path.strip('/')
self._delegate = delegate_for_test or CronServlet.Delegate()
class Delegate(object):
'''CronServlet's runtime dependencies. Override for testing.
'''
- def CreateBranchUtility(self, object_store_creator):
- return BranchUtility.Create(object_store_creator)
-
- def CreateHostFileSystemForBranchAndRevision(self, branch, revision):
- return SubversionFileSystem.Create(branch, revision=revision)
+ def CreateHostFileSystemForRevision(self, revision):
+ return SubversionFileSystem.Create('trunk', revision=revision)
def CreateAppSamplesFileSystem(self, object_store_creator):
# TODO(kalman): CachingFileSystem wrapper for GithubFileSystem, but it's
@@ -71,8 +66,7 @@ class CronServlet(Servlet):
# the time these won't have changed since the last cron run, so it's a
# little wasteful, but hopefully rendering is really fast (if it isn't we
# have a problem).
- channel = self._channel
- logging.info('cron/%s: starting' % channel)
+ logging.info('cron: starting')
# This is returned every time RenderServlet wants to create a new
# ServerInstance.
@@ -88,8 +82,7 @@ class CronServlet(Servlet):
start_time = time.time()
files = [f for f in server_instance.content_cache.GetFromFileListing(d)
if not f.endswith('/')]
- logging.info('cron/%s: rendering %s files from %s...' % (
- channel, len(files), d))
+ logging.info('cron: rendering %s files from %s...' % (len(files), d))
try:
for i, f in enumerate(files):
error = None
@@ -100,18 +93,17 @@ class CronServlet(Servlet):
error = 'Got %s response' % response.status
except DeadlineExceededError:
logging.error(
- 'cron/%s: deadline exceeded rendering %s (%s of %s): %s' % (
- channel, path, i + 1, len(files), traceback.format_exc()))
+ 'cron: deadline exceeded rendering %s (%s of %s): %s' % (
+ path, i + 1, len(files), traceback.format_exc()))
raise
except error:
pass
if error:
- logging.error('cron/%s: error rendering %s: %s' % (
- channel, path, error))
+ logging.error('cron: error rendering %s: %s' % (path, error))
success = False
finally:
- logging.info('cron/%s: rendering %s files from %s took %s seconds' % (
- channel, len(files), d, time.time() - start_time))
+ logging.info('cron: rendering %s files from %s took %s seconds' % (
+ len(files), d, time.time() - start_time))
return success
success = True
@@ -149,26 +141,25 @@ class CronServlet(Servlet):
for filename in server_instance.content_cache.GetFromFileListing(
svn_constants.EXAMPLES_PATH)
if filename.endswith(manifest_json)]
- logging.info('cron/%s: rendering %s example zips...' % (
- channel, len(example_zips)))
+ logging.info('cron: rendering %s example zips...' % len(example_zips))
start_time = time.time()
try:
success = success and all(
get_via_render_servlet('extensions/examples/%s' % z).status == 200
for z in example_zips)
finally:
- logging.info('cron/%s: rendering %s example zips took %s seconds' % (
- channel, len(example_zips), time.time() - start_time))
+ logging.info('cron: rendering %s example zips took %s seconds' % (
+ len(example_zips), time.time() - start_time))
# Also trigger a redirect so that PathCanonicalizer has an opportunity to
# cache file listings.
- logging.info('cron/%s: triggering a redirect...' % channel)
+ logging.info('cron: triggering a redirect...')
redirect_response = get_via_render_servlet('storage.html')
success = success and redirect_response.status == 302
except DeadlineExceededError:
success = False
- logging.info('cron/%s: finished' % channel)
+ logging.info('cron: finished (%s)' % 'success' if success else 'failure')
return (Response.Ok('Success') if success else
Response.InternalError('Failure'))
@@ -178,17 +169,13 @@ class CronServlet(Servlet):
meaning the last revision that the current running version of the server
existed.
'''
- channel = self._channel
delegate = self._delegate
- server_instance_at_head = self._CreateServerInstance(channel, None)
+ server_instance_at_head = self._CreateServerInstance(None)
- get_branch_for_channel = self._GetBranchForChannel
class AppYamlHelperDelegate(AppYamlHelper.Delegate):
def GetHostFileSystemForRevision(self, revision):
- return delegate.CreateHostFileSystemForBranchAndRevision(
- get_branch_for_channel(channel),
- revision)
+ return delegate.CreateHostFileSystemForRevision(revision)
app_yaml_handler = AppYamlHelper(
svn_constants.APP_YAML_PATH,
@@ -206,35 +193,26 @@ class CronServlet(Servlet):
safe_revision = app_yaml_handler.GetFirstRevisionGreaterThan(
delegate.GetAppVersion()) - 1
- logging.info('cron/%s: app version %s is out of date, safe is %s' % (
- channel, delegate.GetAppVersion(), safe_revision))
-
- return self._CreateServerInstance(channel, safe_revision)
+ logging.info('cron: app version %s is out of date, safe is %s' % (
+ delegate.GetAppVersion(), safe_revision))
- def _CreateObjectStoreCreator(self, channel):
- return ObjectStoreCreator(channel, start_empty=True)
+ return self._CreateServerInstance(safe_revision)
- def _GetBranchForChannel(self, channel):
- object_store_creator = self._CreateObjectStoreCreator(channel)
- return (self._delegate.CreateBranchUtility(object_store_creator)
- .GetBranchForChannel(channel))
+ def _CreateObjectStoreCreator(self):
+ return ObjectStoreCreator(start_empty=True)
- def _CreateServerInstance(self, channel, revision):
- object_store_creator = self._CreateObjectStoreCreator(channel)
+ def _CreateServerInstance(self, revision):
+ object_store_creator = self._CreateObjectStoreCreator()
host_file_system = CachingFileSystem(
- self._delegate.CreateHostFileSystemForBranchAndRevision(
- self._GetBranchForChannel(channel),
- revision),
+ self._delegate.CreateHostFileSystemForRevision(revision),
object_store_creator)
app_samples_file_system = self._delegate.CreateAppSamplesFileSystem(
object_store_creator)
compiled_host_fs_factory = CompiledFileSystem.Factory(
host_file_system,
object_store_creator)
- return ServerInstance(channel,
- object_store_creator,
+ return ServerInstance(object_store_creator,
host_file_system,
app_samples_file_system,
- '/static' if channel == 'stable' else
- '/%s/static' % channel,
- compiled_host_fs_factory)
+ compiled_host_fs_factory,
+ '/static')

Powered by Google App Engine
This is Rietveld 408576698