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 915aae50d591693f78ba917875b560d58843a039..14d4b396638ee09680847d5b8b972bb3d41b86a6 100644 |
--- a/chrome/common/extensions/docs/server2/cron_servlet.py |
+++ b/chrome/common/extensions/docs/server2/cron_servlet.py |
@@ -25,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): |
@@ -33,7 +33,6 @@ 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): |
@@ -70,8 +69,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. |
@@ -87,8 +85,7 @@ class CronServlet(Servlet): |
start_time = time.time() |
files = dict( |
CreateURLsFromPaths(server_instance.host_file_system, d, path_prefix)) |
- 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, path in enumerate(files): |
error = None |
@@ -98,18 +95,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 |
@@ -147,24 +143,23 @@ 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)) |
except DeadlineExceededError: |
success = False |
- logging.info("cron/%s: running Redirector cron..." % channel) |
+ logging.info('cron: running Redirector cron...') |
server_instance.redirector.Cron() |
- 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')) |
@@ -174,16 +169,14 @@ 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) |
app_yaml_handler = AppYamlHelper( |
svn_constants.APP_YAML_PATH, |
server_instance_at_head.host_file_system, |
server_instance_at_head.object_store_creator, |
- server_instance_at_head.host_file_system_creator, |
- self._GetBranchForChannel(channel)) |
+ server_instance_at_head.host_file_system_creator) |
if app_yaml_handler.IsUpToDate(delegate.GetAppVersion()): |
# TODO(kalman): return a new ServerInstance at an explicit revision in |
@@ -195,37 +188,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)) |
+ logging.info('cron: app version %s is out of date, safe is %s' % ( |
+ delegate.GetAppVersion(), safe_revision)) |
- return self._CreateServerInstance(channel, safe_revision) |
+ return self._CreateServerInstance(safe_revision) |
- def _CreateObjectStoreCreator(self, channel): |
- return ObjectStoreCreator(channel, start_empty=True) |
- |
- def _GetBranchForChannel(self, channel): |
- object_store_creator = self._CreateObjectStoreCreator(channel) |
- return (self._delegate.CreateBranchUtility(object_store_creator) |
- .GetChannelInfo(channel).branch) |
- |
- def _CreateServerInstance(self, channel, revision): |
- object_store_creator = self._CreateObjectStoreCreator(channel) |
+ def _CreateServerInstance(self, revision): |
+ object_store_creator = ObjectStoreCreator(start_empty=True) |
branch_utility = self._delegate.CreateBranchUtility(object_store_creator) |
host_file_system_creator = self._delegate.CreateHostFileSystemCreator( |
object_store_creator) |
- host_file_system = host_file_system_creator.Create( |
- branch_utility.GetChannelInfo(channel).branch, |
- revision=revision) |
+ host_file_system = host_file_system_creator.Create(revision=revision) |
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, |
- '' if channel == 'stable' else '/%s' % channel, |
+ '', |
compiled_host_fs_factory, |
branch_utility, |
host_file_system_creator) |