| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 from fnmatch import fnmatch | 5 from fnmatch import fnmatch |
| 6 import logging | |
| 7 import mimetypes | 6 import mimetypes |
| 8 import traceback | 7 import traceback |
| 9 import os | 8 import os |
| 10 | 9 |
| 11 from api_data_source import APIDataSource | 10 from api_data_source import APIDataSource |
| 12 from api_list_data_source import APIListDataSource | 11 from api_list_data_source import APIListDataSource |
| 13 from appengine_url_fetcher import AppEngineUrlFetcher | 12 from appengine_url_fetcher import AppEngineUrlFetcher |
| 14 from appengine_wrappers import GetAppVersion, IsDevServer | 13 from appengine_wrappers import GetAppVersion, IsDevServer |
| 14 from availability_finder import AvailabilityFinder |
| 15 from branch_utility import BranchUtility | 15 from branch_utility import BranchUtility |
| 16 from caching_file_system import CachingFileSystem | 16 from caching_file_system import CachingFileSystem |
| 17 from compiled_file_system import CompiledFileSystem | 17 from compiled_file_system import CompiledFileSystem |
| 18 from empty_dir_file_system import EmptyDirFileSystem | 18 from empty_dir_file_system import EmptyDirFileSystem |
| 19 from example_zipper import ExampleZipper | 19 from example_zipper import ExampleZipper |
| 20 from file_system import FileNotFoundError | 20 from file_system import FileNotFoundError |
| 21 from github_file_system import GithubFileSystem | 21 from github_file_system import GithubFileSystem |
| 22 from intro_data_source import IntroDataSource | 22 from intro_data_source import IntroDataSource |
| 23 from local_file_system import LocalFileSystem | 23 from local_file_system import LocalFileSystem |
| 24 from object_store_creator import ObjectStoreCreator | 24 from object_store_creator import ObjectStoreCreator |
| 25 from offline_file_system import OfflineFileSystem | 25 from offline_file_system import OfflineFileSystem |
| 26 from path_canonicalizer import PathCanonicalizer | 26 from path_canonicalizer import PathCanonicalizer |
| 27 from reference_resolver import ReferenceResolver | 27 from reference_resolver import ReferenceResolver |
| 28 from samples_data_source import SamplesDataSource | 28 from samples_data_source import SamplesDataSource |
| 29 from sidenav_data_source import SidenavDataSource | 29 from sidenav_data_source import SidenavDataSource |
| 30 from subversion_file_system import SubversionFileSystem | |
| 31 import svn_constants | 30 import svn_constants |
| 32 from template_data_source import TemplateDataSource | 31 from template_data_source import TemplateDataSource |
| 32 from test_branch_utility import TestBranchUtility |
| 33 from test_file_system import TestFileSystem |
| 33 from test_object_store import TestObjectStore | 34 from test_object_store import TestObjectStore |
| 34 from third_party.json_schema_compiler.model import UnixName | 35 from third_party.json_schema_compiler.model import UnixName |
| 35 import url_constants | 36 import url_constants |
| 36 | 37 |
| 37 class ServerInstance(object): | 38 class ServerInstance(object): |
| 38 def __init__(self, | 39 def __init__(self, |
| 39 channel, | 40 channel, |
| 40 object_store_creator, | 41 object_store_creator, |
| 41 host_file_system, | 42 host_file_system, |
| 42 app_samples_file_system, | 43 app_samples_file_system, |
| 43 base_path, | 44 base_path, |
| 44 compiled_fs_factory): | 45 compiled_fs_factory, |
| 46 branch_utility, |
| 47 create_file_system): |
| 45 self.channel = channel | 48 self.channel = channel |
| 46 | 49 |
| 47 self.object_store_creator = object_store_creator | 50 self.object_store_creator = object_store_creator |
| 48 | 51 |
| 49 self.host_file_system = host_file_system | 52 self.host_file_system = host_file_system |
| 50 | 53 |
| 51 self.app_samples_file_system = app_samples_file_system | 54 self.app_samples_file_system = app_samples_file_system |
| 52 | 55 |
| 53 self.compiled_host_fs_factory = compiled_fs_factory | 56 self.compiled_host_fs_factory = compiled_fs_factory |
| 54 | 57 |
| 58 self.availability_finder_factory = AvailabilityFinder.Factory( |
| 59 object_store_creator, |
| 60 self.compiled_host_fs_factory, |
| 61 branch_utility, |
| 62 create_file_system) |
| 63 |
| 55 self.api_list_data_source_factory = APIListDataSource.Factory( | 64 self.api_list_data_source_factory = APIListDataSource.Factory( |
| 56 self.compiled_host_fs_factory, | 65 self.compiled_host_fs_factory, |
| 57 svn_constants.API_PATH, | 66 svn_constants.API_PATH, |
| 58 svn_constants.PUBLIC_TEMPLATE_PATH) | 67 svn_constants.PUBLIC_TEMPLATE_PATH) |
| 59 | 68 |
| 60 self.api_data_source_factory = APIDataSource.Factory( | 69 self.api_data_source_factory = APIDataSource.Factory( |
| 61 self.compiled_host_fs_factory, | 70 self.compiled_host_fs_factory, |
| 62 svn_constants.API_PATH) | 71 svn_constants.API_PATH, |
| 72 self.availability_finder_factory) |
| 63 | 73 |
| 64 self.ref_resolver_factory = ReferenceResolver.Factory( | 74 self.ref_resolver_factory = ReferenceResolver.Factory( |
| 65 self.api_data_source_factory, | 75 self.api_data_source_factory, |
| 66 self.api_list_data_source_factory, | 76 self.api_list_data_source_factory, |
| 67 object_store_creator) | 77 object_store_creator) |
| 68 | 78 |
| 69 self.api_data_source_factory.SetReferenceResolverFactory( | 79 self.api_data_source_factory.SetReferenceResolverFactory( |
| 70 self.ref_resolver_factory) | 80 self.ref_resolver_factory) |
| 71 | 81 |
| 72 # Note: samples are super slow in the dev server because it doesn't support | 82 # Note: samples are super slow in the dev server because it doesn't support |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 134 |
| 125 @staticmethod | 135 @staticmethod |
| 126 def ForTest(file_system): | 136 def ForTest(file_system): |
| 127 object_store_creator = ObjectStoreCreator.ForTest() | 137 object_store_creator = ObjectStoreCreator.ForTest() |
| 128 return ServerInstance('test', | 138 return ServerInstance('test', |
| 129 object_store_creator, | 139 object_store_creator, |
| 130 file_system, | 140 file_system, |
| 131 EmptyDirFileSystem(), | 141 EmptyDirFileSystem(), |
| 132 '', | 142 '', |
| 133 CompiledFileSystem.Factory(file_system, | 143 CompiledFileSystem.Factory(file_system, |
| 134 object_store_creator)) | 144 object_store_creator), |
| 145 TestBranchUtility(), |
| 146 lambda version: file_system) |
| 135 | 147 |
| 136 @staticmethod | 148 @staticmethod |
| 137 def ForLocal(): | 149 def ForLocal(): |
| 138 channel = 'trunk' | 150 channel = 'trunk' |
| 139 object_store_creator = ObjectStoreCreator(channel, | 151 object_store_creator = ObjectStoreCreator(channel, |
| 140 start_empty=False, | 152 start_empty=False, |
| 141 store_type=TestObjectStore) | 153 store_type=TestObjectStore) |
| 142 file_system = CachingFileSystem(LocalFileSystem.Create(), | 154 def create_file_system(version): |
| 143 object_store_creator) | 155 return CachingFileSystem(LocalFileSystem.Create(), object_store_creator) |
| 156 trunk_file_system = create_file_system('trunk') |
| 144 return ServerInstance( | 157 return ServerInstance( |
| 145 channel, | 158 channel, |
| 146 object_store_creator, | 159 object_store_creator, |
| 147 file_system, | 160 trunk_file_system, |
| 148 EmptyDirFileSystem(), | 161 EmptyDirFileSystem(), |
| 149 '', | 162 '', |
| 150 CompiledFileSystem.Factory(file_system, object_store_creator)) | 163 CompiledFileSystem.Factory(trunk_file_system, object_store_creator), |
| 164 TestBranchUtility(), |
| 165 create_file_system) |
| OLD | NEW |