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

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

Issue 13896007: Devserver: run the cron over the examples. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try again to avoid .svn Created 7 years, 8 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/server_instance.py
diff --git a/chrome/common/extensions/docs/server2/server_instance.py b/chrome/common/extensions/docs/server2/server_instance.py
index 8c5e1b69e180ad2d89212fe562cd5a247cd94777..54550b3c8b7ec3880264dc8d189523bd61824860 100644
--- a/chrome/common/extensions/docs/server2/server_instance.py
+++ b/chrome/common/extensions/docs/server2/server_instance.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
from fnmatch import fnmatch
+import logging
import mimetypes
import os
@@ -184,7 +185,6 @@ class ServerInstance(object):
svn_constants.PRIVATE_TEMPLATE_PATH)
self.example_zipper = ExampleZipper(
- self.svn_file_system,
self.compiled_fs_factory,
svn_constants.DOCS_PATH)
@@ -198,49 +198,40 @@ class ServerInstance(object):
"""Fetch a resource in the 'static' directory.
"""
mimetype = mimetypes.guess_type(path)[0] or 'text/plain'
- try:
- result = self.content_cache.GetFromFile(
- svn_constants.DOCS_PATH + '/' + path,
- binary=_IsBinaryMimetype(mimetype))
- except FileNotFoundError:
- return None
+ result = self.content_cache.GetFromFile(
+ svn_constants.DOCS_PATH + '/' + path,
+ binary=_IsBinaryMimetype(mimetype))
response.headers['content-type'] = mimetype
return result
def Get(self, path, request, response):
templates = self.template_data_source_factory.Create(request, path)
- if path.rsplit('/', 1)[-1] in ('favicon.ico', 'robots.txt'):
- response.set_status(404)
- response.out.write(templates.Render('404'))
- return
-
content = None
- if fnmatch(path, 'extensions/examples/*.zip'):
- try:
+ try:
+ if fnmatch(path, 'extensions/examples/*.zip'):
content = self.example_zipper.Create(
path[len('extensions/'):-len('.zip')])
response.headers['content-type'] = 'application/zip'
- except FileNotFoundError:
- content = None
- elif path.startswith('extensions/examples/'):
- mimetype = mimetypes.guess_type(path)[0] or 'text/plain'
- try:
+ elif path.startswith('extensions/examples/'):
+ mimetype = mimetypes.guess_type(path)[0] or 'text/plain'
content = self.content_cache.GetFromFile(
'%s/%s' % (svn_constants.DOCS_PATH, path[len('extensions/'):]),
binary=_IsBinaryMimetype(mimetype))
response.headers['content-type'] = 'text/plain'
- except FileNotFoundError:
- content = None
- elif path.startswith('static/'):
- content = self._FetchStaticResource(path, response)
- elif path.endswith('.html'):
- content = templates.Render(path)
+ elif path.startswith('static/'):
+ content = self._FetchStaticResource(path, response)
+ elif path.endswith('.html'):
+ content = templates.Render(path)
+ except FileNotFoundError as e:
+ logging.warning(e)
response.headers['x-frame-options'] = 'sameorigin'
- if content:
- response.headers['cache-control'] = 'max-age=300'
- response.out.write(content)
- else:
+ if content is None:
response.set_status(404);
response.out.write(templates.Render('404'))
+ else:
+ if not content:
+ logging.error('%s had empty content' % path)
+ response.headers['cache-control'] = 'max-age=300'
+ response.out.write(content)

Powered by Google App Engine
This is Rietveld 408576698