예제 #1
0
    def _HandleGet(self, path):
        channel_name, real_path = BranchUtility.SplitChannelNameFromPath(path)

        if channel_name == _DEFAULT_CHANNEL:
            self.redirect('/%s' % real_path)
            return

        if channel_name is None:
            channel_name = _DEFAULT_CHANNEL

        # TODO(kalman): Check if |path| is a directory and serve path/index.html
        # rather than special-casing apps/extensions.
        if real_path.strip('/') == 'apps':
            real_path = 'apps/index.html'
        if real_path.strip('/') == 'extensions':
            real_path = 'extensions/index.html'

        server_instance = ServerInstance.GetOrCreate(channel_name)

        canonical_path = server_instance.path_canonicalizer.Canonicalize(
            real_path)
        if real_path != canonical_path:
            self.redirect(canonical_path)
            return

        ServerInstance.GetOrCreate(channel_name).Get(real_path, self.request,
                                                     self.response)
예제 #2
0
  def testWithDifferentBasePath(self):
    file_system = TestFileSystem({
      'chrome_sidenav.json': json.dumps([
        { 'href': '/H1.html' },
        { 'href': '/H2.html' },
        { 'href': '/base/path/H2.html' },
        { 'href': 'https://qualified/X1.html' },
        {
          'href': 'H3.html',
          'items': [{
            'href': 'H4.html'
          }]
        },
      ])
    }, relative_to=JSON_TEMPLATES)

    expected = [
      {'href': '/base/path/H1.html', 'level': 2, 'related': True},
      {'href': '/base/path/H2.html', 'level': 2, 'selected': True, 'related': True},
      {'href': '/base/path/base/path/H2.html', 'level': 2, 'related': True},
      {'href': 'https://qualified/X1.html', 'level': 2, 'related': True},
      {'items': [
        {'href': '/base/path/H4.html', 'level': 3}
      ],
      'href': '/base/path/H3.html', 'level': 2, 'related': True}
    ]

    server_instance = ServerInstance.ForTest(file_system,
                                             base_path='/base/path/')
    sidenav_data_source = SidenavDataSource(server_instance,
                                            Request.ForTest('/H2.html'))

    log_output = CaptureLogging(
        lambda: self.assertEqual(expected, sidenav_data_source.get('chrome')))
    self.assertEqual(2, len(log_output))
예제 #3
0
    def CreateServerInstanceForChannel(self, channel):
        base_object_store_creator = ObjectStoreCreator(channel,
                                                       start_empty=False)
        # TODO(fj): Use OfflineFileSystem here once all json/idl files in api/
        # are pulled into data store by cron jobs.
        base_file_system = CachingFileSystem(
            self._delegate.CreateHostFileSystemForBranch(channel),
            base_object_store_creator)
        base_compiled_fs_factory = CompiledFileSystem.Factory(
            base_file_system, base_object_store_creator)

        object_store_creator = ObjectStoreCreator('trunk@%s' % self._issue,
                                                  start_empty=False)
        rietveld_patcher = CachingRietveldPatcher(
            RietveldPatcher(
                svn_constants.EXTENSIONS_PATH, self._issue,
                AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER)),
            object_store_creator)
        patched_file_system = PatchedFileSystem(base_file_system,
                                                rietveld_patcher)
        patched_compiled_fs_factory = CompiledFileSystem.Factory(
            patched_file_system, object_store_creator)

        compiled_fs_factory = ChainedCompiledFileSystem.Factory([
            (patched_compiled_fs_factory, patched_file_system),
            (base_compiled_fs_factory, base_file_system)
        ])
        return ServerInstance(
            channel, object_store_creator, patched_file_system,
            self._delegate.CreateAppSamplesFileSystem(
                base_object_store_creator), '/_patch/%s' % self._issue,
            compiled_fs_factory)
    def CreateServerInstance(self):
        object_store_creator = ObjectStoreCreator(start_empty=False)
        branch_utility = self._delegate.CreateBranchUtility(
            object_store_creator)
        host_file_system_creator = self._delegate.CreateHostFileSystemCreator(
            object_store_creator)
        # offline=False because a patch can rely on files that are already in SVN
        # repository but not yet pulled into data store by cron jobs (a typical
        # example is to add documentation for an existing API).
        base_file_system = CachingFileSystem(
            host_file_system_creator.Create(offline=False),
            object_store_creator)
        base_compiled_fs_factory = CompiledFileSystem.Factory(
            base_file_system, object_store_creator)

        rietveld_patcher = CachingRietveldPatcher(
            RietveldPatcher(
                svn_constants.EXTENSIONS_PATH, self._issue,
                AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER)),
            object_store_creator)
        patched_file_system = PatchedFileSystem(base_file_system,
                                                rietveld_patcher)
        patched_compiled_fs_factory = CompiledFileSystem.Factory(
            patched_file_system, object_store_creator)

        compiled_fs_factory = ChainedCompiledFileSystem.Factory([
            (patched_compiled_fs_factory, patched_file_system),
            (base_compiled_fs_factory, base_file_system)
        ])

        return ServerInstance(
            object_store_creator, patched_file_system,
            self._delegate.CreateAppSamplesFileSystem(object_store_creator),
            '/_patch/%s' % self._issue, compiled_fs_factory, branch_utility,
            host_file_system_creator)
예제 #5
0
 def setUp(self):
     server_instance = ServerInstance.ForTest(
         file_system=TestFileSystem({}))
     self._samples_model = server_instance.platform_bundle.GetSamplesModel(
         'apps')
     self._samples_model._samples_cache = _FakeCache(
         json.loads(_ReadLocalFile('samples.json')))
예제 #6
0
 def setUp(self):
   server_instance = ServerInstance.ForTest(
       TestFileSystem(_TEST_DATA, relative_to=CHROME_EXTENSIONS))
   # APIListDataSource takes a request but doesn't use it,
   # so put None
   self._api_list = APIListDataSource(server_instance, None)
   self.maxDiff = None
예제 #7
0
 def setUp(self):
     server_instance = ServerInstance.ForTest(TestFileSystem(_TEST_DATA))
     self._factory = APIListDataSource.Factory(
         server_instance.compiled_fs_factory,
         server_instance.host_file_system_provider.GetTrunk(),
         server_instance.features_bundle,
         server_instance.object_store_creator)
예제 #8
0
 def setUp(self):
     server_instance = ServerInstance.ForTest(
         file_system=TestFileSystem(_TEST_FS))
     # Don't randomize the owners to avoid testing issues.
     self._owners_ds = OwnersDataSource(server_instance,
                                        Request.ForTest('/'),
                                        randomize=False)
예제 #9
0
 def _GetInstanceForBranch(self, branch):
     if branch in SERVER_INSTANCES:
         return SERVER_INSTANCES[branch]
     if branch == 'local':
         fetcher = LocalFetcher(EXTENSIONS_PATH)
         # No cache for local doc server.
         cache_timeout_seconds = 0
     else:
         fetcher = SubversionFetcher(branch, EXTENSIONS_PATH, urlfetch)
         cache_timeout_seconds = 300
     cache_builder = FetcherCache.Builder(fetcher, cache_timeout_seconds)
     api_data_source = APIDataSource(cache_builder, API_PATH)
     intro_data_source = IntroDataSource(cache_builder,
                                         [INTRO_PATH, ARTICLE_PATH])
     samples_data_source = SamplesDataSource(fetcher, cache_builder,
                                             EXAMPLES_PATH)
     template_data_source = TemplateDataSource(
         branch, api_data_source, intro_data_source, samples_data_source,
         cache_builder, [PUBLIC_TEMPLATE_PATH, PRIVATE_TEMPLATE_PATH])
     example_zipper = ExampleZipper(fetcher, cache_builder, DOCS_PATH,
                                    EXAMPLES_PATH)
     SERVER_INSTANCES[branch] = ServerInstance(template_data_source,
                                               example_zipper,
                                               cache_builder)
     return SERVER_INSTANCES[branch]
예제 #10
0
    def _HandleCron(self, path):
        # Cron strategy:
        #
        # Find all public template files and static files, and render them. Most of
        # 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).
        class MockResponse(object):
            def __init__(self):
                self.status = 200
                self.out = StringIO()
                self.headers = {}

            def set_status(self, status):
                self.status = status

            def clear(self, *args):
                pass

        class MockRequest(object):
            def __init__(self, path):
                self.headers = {}
                self.path = path
                self.url = '//localhost/%s' % path

        channel = path.split('/')[-1]
        logging.info('cron/%s: starting' % channel)

        server_instance = ServerInstance.GetOrCreate(channel)

        def run_cron_for_dir(d):
            error = None
            start_time = time.time()
            files = [
                f for f in server_instance.content_cache.GetFromFileListing(d)
                if not f.endswith('/')
            ]
            for f in files:
                try:
                    server_instance.Get(f, MockRequest(f), MockResponse())
                except error:
                    logging.error('cron/%s: error rendering %s/%s: %s' %
                                  (channel, d, f, error))
            logging.info('cron/%s: rendering %s files in %s took %s seconds' %
                         (channel, len(files), d, time.time() - start_time))
            return error

        # Don't use "or" since we want to evaluate everything no matter what.
        was_error = any((run_cron_for_dir(svn_constants.PUBLIC_TEMPLATE_PATH),
                         run_cron_for_dir(svn_constants.STATIC_PATH)))

        if was_error:
            self.response.status = 500
            self.response.out.write('Failure')
        else:
            self.response.status = 200
            self.response.out.write('Success')

        logging.info('cron/%s: finished' % channel)
예제 #11
0
    def setUp(self):
        self._base_path = Server2Path('test_data', 'test_json')

        server_instance = ServerInstance.ForTest(
            TestFileSystem(CANNED_TRUNK_FS_DATA, relative_to=EXTENSIONS))
        self._json_cache = server_instance.compiled_fs_factory.ForJson(
            server_instance.host_file_system_provider.GetTrunk())
        self._api_models = server_instance.api_models

        # Used for testGetApiAvailability() so that valid-ish data is processed.
        server_instance = ServerInstance.ForTest(
            file_system_provider=_FakeHostFileSystemProvider(
                CANNED_API_FILE_SYSTEM_DATA))
        self._avail_api_models = server_instance.api_models
        self._avail_json_cache = server_instance.compiled_fs_factory.ForJson(
            server_instance.host_file_system_provider.GetTrunk())
        self._avail_finder = server_instance.availability_finder
예제 #12
0
def _CreateTestDataSource(base_dir):
    '''TemplateDataSource is not instantiated directly, rather, its methods
  are invoked through a subclass of it, which has as its only data the
  directory in which TemplateDataSource methods should act on. Thus, we test
  TemplateDataSource indirectly through the TestDataSource class
  '''
    return TestDataSource(
        ServerInstance.ForLocal(),
        '%stest_data/template_data_source/%s/' % (SERVER2, base_dir))
예제 #13
0
 def setUp(self):
     server_instance = ServerInstance.ForTest(
         file_system_provider=FakeHostFileSystemProvider(
             CANNED_API_FILE_SYSTEM_DATA))
     self._api_models = server_instance.platform_bundle.GetAPIModels(
         'extensions')
     self._json_cache = server_instance.compiled_fs_factory.ForJson(
         server_instance.host_file_system_provider.GetMaster())
     self._avail_finder = server_instance.platform_bundle.GetAvailabilityFinder(
         'extensions')
예제 #14
0
def _GetInstanceForBranch(channel_name, local_path):
  branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name)

  # The key for the server is a tuple of |channel_name| with |branch|, since
  # sometimes stable and beta point to the same branch.
  instance_key = _MakeInstanceKey(channel_name, branch)
  instance = SERVER_INSTANCES.get(instance_key, None)
  if instance is not None:
    return instance

  branch_memcache = InMemoryObjectStore(branch)
  if branch == 'local':
    file_system = LocalFileSystem(local_path)
  else:
    file_system = _CreateMemcacheFileSystem(branch, branch_memcache)

  cache_factory = CompiledFileSystem.Factory(file_system, branch_memcache)
  api_list_data_source_factory = APIListDataSource.Factory(cache_factory,
                                                           file_system,
                                                           API_PATH,
                                                           PUBLIC_TEMPLATE_PATH)
  intro_data_source_factory = IntroDataSource.Factory(
      cache_factory,
      [INTRO_PATH, ARTICLE_PATH])
  samples_data_source_factory = SamplesDataSource.Factory(
      channel_name,
      file_system,
      GITHUB_FILE_SYSTEM,
      cache_factory,
      GITHUB_COMPILED_FILE_SYSTEM,
      api_list_data_source_factory,
      EXAMPLES_PATH)
  api_data_source_factory = APIDataSource.Factory(cache_factory,
                                                  API_PATH,
                                                  samples_data_source_factory)
  template_data_source_factory = TemplateDataSource.Factory(
      channel_name,
      api_data_source_factory,
      api_list_data_source_factory,
      intro_data_source_factory,
      samples_data_source_factory,
      KNOWN_ISSUES_DATA_SOURCE,
      cache_factory,
      PUBLIC_TEMPLATE_PATH,
      PRIVATE_TEMPLATE_PATH)
  example_zipper = ExampleZipper(file_system,
                                 cache_factory,
                                 DOCS_PATH)

  instance = ServerInstance(template_data_source_factory,
                            example_zipper,
                            cache_factory)
  SERVER_INSTANCES[instance_key] = instance
  return instance
 def setUp(self):
     server_instance = ServerInstance.ForTest(
         TestFileSystem(_TEST_DATA, relative_to=EXTENSIONS))
     self._factory = APIListDataSource.Factory(
         server_instance.compiled_fs_factory,
         server_instance.host_file_system_provider.GetTrunk(),
         server_instance.features_bundle,
         server_instance.object_store_creator, server_instance.api_models,
         server_instance.availability_finder,
         server_instance.api_categorizer)
     self.maxDiff = None
    def testSidenavDataSource(self):
        file_system = MockFileSystem(
            TestFileSystem(
                {
                    'chrome_sidenav.json':
                    json.dumps([{
                        'title': 'H1',
                        'href': 'H1.html',
                        'items': [{
                            'title': 'H2',
                            'href': '/H2.html'
                        }]
                    }])
                },
                relative_to=JSON_TEMPLATES))

        expected = [{
            'level':
            2,
            'child_selected':
            True,
            'title':
            'H1',
            'href':
            '/H1.html',
            'items': [{
                'level': 3,
                'selected': True,
                'related': True,
                'title': 'H2',
                'href': '/H2.html',
                'parent': {
                    'href': '/H1.html',
                    'title': 'H1'
                }
            }]
        }]

        sidenav_data_source = SidenavDataSource(
            ServerInstance.ForTest(file_system), Request.ForTest('/H2.html'))
        self.assertTrue(*file_system.CheckAndReset())

        log_output = CaptureLogging(lambda: self.assertEqual(
            expected, sidenav_data_source.get('chrome')))

        self.assertEqual(1, len(log_output))
        self.assertTrue(log_output[0].msg.startswith(
            'Paths in sidenav must be qualified.'))

        # Test that only a single file is read when creating the sidenav, so that
        # we can be confident in the compiled_file_system.SingleFile annotation.
        self.assertTrue(*file_system.CheckAndReset(
            read_count=1, stat_count=1, read_resolve_count=1))
예제 #17
0
 def _CreateServerInstance(self, channel, revision):
     object_store_creator = self._CreateObjectStoreCreator(channel)
     host_file_system = CachingFileSystem(
         self._delegate.CreateHostFileSystemForBranchAndRevision(
             self._GetBranchForChannel(channel), 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, host_file_system,
                           app_samples_file_system,
                           '' if channel == 'stable' else '/%s' % channel,
                           compiled_host_fs_factory)
  def setUp(self):
    self._base_path = Server2Path('test_data', 'test_json')

    server_instance = ServerInstance.ForTest(
        TestFileSystem(CANNED_MASTER_FS_DATA, relative_to=CHROME_EXTENSIONS))
    file_system = server_instance.host_file_system_provider.GetMaster()
    self._json_cache = server_instance.compiled_fs_factory.ForJson(file_system)
    self._features_bundle = FeaturesBundle(file_system,
                                           server_instance.compiled_fs_factory,
                                           server_instance.object_store_creator,
                                           'extensions')
    self._api_models = server_instance.platform_bundle.GetAPIModels(
        'extensions')
    self._fake_availability = AvailabilityInfo(ChannelInfo('stable', '396', 5))
예제 #19
0
def _CreateServerInstance(commit):
    '''Creates a ServerInstance based on origin/master.
  '''
    object_store_creator = ObjectStoreCreator(
        start_empty=False, store_type=PersistentObjectStoreFake)
    branch_utility = BranchUtility.Create(object_store_creator)
    host_file_system_provider = HostFileSystemProvider(object_store_creator,
                                                       pinned_commit=commit)
    gcs_file_system_provider = CloudStorageFileSystemProvider(
        object_store_creator)
    return ServerInstance(object_store_creator,
                          CompiledFileSystem.Factory(object_store_creator),
                          branch_utility, host_file_system_provider,
                          gcs_file_system_provider)
예제 #20
0
 def CreateServerInstance(self):
     object_store_creator = ObjectStoreCreator(start_empty=False)
     branch_utility = self._delegate.CreateBranchUtility(
         object_store_creator)
     # In production have offline=True so that we can catch cron errors.  In
     # development it's annoying to have to run the cron job, so offline=False.
     host_file_system_provider = self._delegate.CreateHostFileSystemProvider(
         object_store_creator, offline=not IsDevServer())
     github_file_system_provider = self._delegate.CreateGithubFileSystemProvider(
         object_store_creator)
     return ServerInstance(object_store_creator,
                           CompiledFileSystem.Factory(object_store_creator),
                           branch_utility, host_file_system_provider,
                           github_file_system_provider)
예제 #21
0
    def CreateServerInstance(self):
        # start_empty=False because a patch can rely on files that are already in
        # SVN repository but not yet pulled into data store by cron jobs (a typical
        # example is to add documentation for an existing API).
        object_store_creator = ObjectStoreCreator(start_empty=False)

        unpatched_file_system = self._delegate.CreateHostFileSystemProvider(
            object_store_creator).GetTrunk()

        rietveld_patcher = CachingRietveldPatcher(
            RietveldPatcher(
                self._issue,
                AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER)),
            object_store_creator)

        patched_file_system = PatchedFileSystem(unpatched_file_system,
                                                rietveld_patcher)

        patched_host_file_system_provider = (
            self._delegate.CreateHostFileSystemProvider(
                object_store_creator,
                # The patched file system needs to be online otherwise it'd be
                # impossible to add files in the patches.
                offline=False,
                # The trunk file system for this creator should be the patched one.
                default_trunk_instance=patched_file_system))

        combined_compiled_fs_factory = ChainedCompiledFileSystem.Factory(
            [unpatched_file_system], object_store_creator)

        branch_utility = self._delegate.CreateBranchUtility(
            object_store_creator)

        server_instance = ServerInstance(
            object_store_creator,
            combined_compiled_fs_factory,
            branch_utility,
            patched_host_file_system_provider,
            self._delegate.CreateGithubFileSystemProvider(
                object_store_creator),
            CloudStorageFileSystemProvider(object_store_creator),
            base_path='/_patch/%s/' % self._issue)

        # HACK: if content_providers.json changes in this patch then the cron needs
        # to be re-run to pull in the new configuration.
        _, _, modified = rietveld_patcher.GetPatchedFiles()
        if CONTENT_PROVIDERS in modified:
            server_instance.content_providers.Cron().Get()

        return server_instance
    def testRefresh(self):
        file_system = TestFileSystem(
            {'chrome_sidenav.json': '[{ "title": "H1" }]'},
            relative_to=JSON_TEMPLATES)

        # Ensure Refresh doesn't rely on request.
        sidenav_data_source = SidenavDataSource(
            ServerInstance.ForTest(file_system), request=None)
        sidenav_data_source.Refresh().Get()

        # If Refresh fails, chrome_sidenav.json will not be cached, and the
        # cache_data access will fail.
        # TODO(jshumway): Make a non hack version of this check.
        sidenav_data_source._cache._file_object_store.Get(
            '%schrome_sidenav.json' % JSON_TEMPLATES).Get().cache_data
 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(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(object_store_creator, host_file_system,
                           app_samples_file_system, '',
                           compiled_host_fs_factory, branch_utility,
                           host_file_system_creator)
  def testCron(self):
    file_system = TestFileSystem({
      'apps_sidenav.json': '[{ "title": "H1" }]' ,
      'extensions_sidenav.json': '[{ "title": "H2" }]'
    }, relative_to=JSON_TEMPLATES)

    # Ensure Cron doesn't rely on request.
    sidenav_data_source = SidenavDataSource(
        ServerInstance.ForTest(file_system), request=None)
    sidenav_data_source.Cron().Get()

    # If Cron fails, apps_sidenav.json will not be cached, and the _cache_data
    # access will fail.
    # TODO(jshumway): Make a non hack version of this check.
    sidenav_data_source._cache._file_object_store.Get(
        '%s/apps_sidenav.json' % JSON_TEMPLATES).Get()._cache_data
예제 #25
0
 def _CreateServerInstance(self, revision):
     '''Creates a ServerInstance pinned to |revision|, or HEAD if None.
 NOTE: If passed None it's likely that during the cron run patches will be
 submitted at HEAD, which may change data underneath the cron run.
 '''
     object_store_creator = ObjectStoreCreator(start_empty=True)
     branch_utility = self._delegate.CreateBranchUtility(
         object_store_creator)
     host_file_system_provider = self._delegate.CreateHostFileSystemProvider(
         object_store_creator, max_trunk_revision=revision)
     github_file_system_provider = self._delegate.CreateGithubFileSystemProvider(
         object_store_creator)
     return ServerInstance(object_store_creator,
                           CompiledFileSystem.Factory(object_store_creator),
                           branch_utility, host_file_system_provider,
                           github_file_system_provider)
  def setUp(self):
    tabs_unmodified_versions = (16, 20, 23, 24)
    self._branch_utility = BranchUtility(
        os.path.join('branch_utility', 'first.json'),
        os.path.join('branch_utility', 'second.json'),
        FakeUrlFetcher(Server2Path('test_data')),
        ObjectStoreCreator.ForTest())
    self._node_fs_creator = FakeHostFileSystemProvider(TABS_SCHEMA_BRANCHES)
    self._node_fs_iterator = HostFileSystemIterator(self._node_fs_creator,
                                                    self._branch_utility)
    test_object_store = ObjectStoreCreator.ForTest()
    self._avail_finder = AvailabilityFinder(
        self._branch_utility,
        CompiledFileSystem.Factory(test_object_store),
        self._node_fs_iterator,
        self._node_fs_creator.GetMaster(),
        test_object_store,
        'extensions',
        SchemaProcessorFactoryForTest())

    server_instance = ServerInstance.ForTest(
        file_system_provider=FakeHostFileSystemProvider(
            TABS_SCHEMA_BRANCHES))
    self._api_models = server_instance.platform_bundle.GetAPIModels(
        'extensions')
    self._json_cache = server_instance.compiled_fs_factory.ForJson(
        server_instance.host_file_system_provider.GetMaster())

    # Imitate the actual SVN file system by incrementing the stats for paths
    # where an API schema has changed.
    last_stat = type('last_stat', (object,), {'val': 0})

    def stat_paths(file_system, channel_info):
      if channel_info.version not in tabs_unmodified_versions:
        last_stat.val += 1
      # HACK: |file_system| is a MockFileSystem backed by a TestFileSystem.
      # Increment the TestFileSystem stat count.
      file_system._file_system.IncrementStat(by=last_stat.val)
      # Continue looping. The iterator will stop after 'master' automatically.
      return True

    # Use the HostFileSystemIterator created above to change global stat values
    # for the TestFileSystems that it creates.
    self._node_fs_iterator.Ascending(
        # The earliest version represented with the tabs' test data is 13.
        self._branch_utility.GetStableChannelInfo(13),
        stat_paths)
 def CreateServerInstance(self):
     object_store_creator = ObjectStoreCreator(start_empty=False)
     branch_utility = self._delegate.CreateBranchUtility(
         object_store_creator)
     # In production have offline=True so that we can catch cron errors. In
     # development it's annoying to have to run the cron job, so offline=False.
     # Note that offline=True if running on any appengine server due to
     # http://crbug.com/345361.
     host_file_system_provider = self._delegate.CreateHostFileSystemProvider(
         object_store_creator,
         offline=not (IsDevServer() or IsReleaseServer()))
     github_file_system_provider = self._delegate.CreateGithubFileSystemProvider(
         object_store_creator)
     return ServerInstance(
         object_store_creator,
         CompiledFileSystem.Factory(object_store_creator), branch_utility,
         host_file_system_provider, github_file_system_provider,
         CloudStorageFileSystemProvider(object_store_creator))
예제 #28
0
 def CreateServerInstance(self):
     object_store_creator = ObjectStoreCreator(start_empty=False)
     branch_utility = self._delegate.CreateBranchUtility(
         object_store_creator)
     # In production have offline=True so that we can catch cron errors. In
     # development it's annoying to have to run the cron job, so offline=False.
     #
     # XXX(kalman): The above comment is not true, I have temporarily disabled
     # this while the cron is running out of memory and not reliably finishing.
     # In the meantime, live dangerously and fetch content if it's not there.
     # I.e. never offline. See http://crbug.com/345361.
     host_file_system_provider = self._delegate.CreateHostFileSystemProvider(
         object_store_creator, offline=False
     )  # XXX(kalman): condition should be "not IsDevServer()"
     github_file_system_provider = self._delegate.CreateGithubFileSystemProvider(
         object_store_creator)
     return ServerInstance(
         object_store_creator,
         CompiledFileSystem.Factory(object_store_creator), branch_utility,
         host_file_system_provider, github_file_system_provider,
         CloudStorageFileSystemProvider(object_store_creator))
예제 #29
0
 def _GetInstanceForBranch(self, branch):
   if branch in SERVER_INSTANCES:
     return SERVER_INSTANCES[branch]
   if branch == 'local':
     fetcher = LocalFetcher(EXTENSIONS_PATH)
     # No cache for local doc server.
     cache_timeout_seconds = 0
   else:
     fetcher = SubversionFetcher(branch, EXTENSIONS_PATH, urlfetch)
     cache_timeout_seconds = 300
   cache_builder = FetcherCache.Builder(fetcher, cache_timeout_seconds)
   api_data_source = APIDataSource(cache_builder, API_PATH)
   template_data_source = TemplateDataSource(
       branch,
       api_data_source,
       cache_builder,
       [PUBLIC_TEMPLATE_PATH, PRIVATE_TEMPLATE_PATH])
   SERVER_INSTANCES[branch] = ServerInstance(
       template_data_source,
       cache_builder)
   return SERVER_INSTANCES[branch]
예제 #30
0
 def CreateServerInstance(self):
     return ServerInstance.ForTest(LocalFileSystem.Create())