def handle(self, *args, **options):
     for ds in datasource.datasources_from_entrypoints():
         print(ds)
         try:
             scripts.cache_latest_values(ds)
         except:
             logger.exception('skipping datasource {0}'.format(ds))
 def handle(self, *args, **options):
     for ds in datasource.datasources_from_entrypoints():
         try:
             scripts.cache_latest_values(
                 ds, allow_cache=(options['no_cache'] == False))
         except:
             logger.exception(
                 'Exception for datasource {0}, skipping it'.format(ds))
示例#3
0
    def test_returns_loaded_entrypoints(self):
        entrypoint = mock.MagicMock()
        factory = mock.MagicMock(return_value=["whee"])
        entrypoint.load = mock.MagicMock(return_value=factory)

        with mock.patch(
            'lizard_datasource.datasource.datasource_entrypoints',
            return_value=[entrypoint]):
            self.assertEquals(
                datasource.datasources_from_entrypoints(),
                ["whee"])
示例#4
0
def cache_latest_values(*args, **options):
    """Celery task for cache_latest_values.

    Original from the cache_latest_values management command."""

    # Set host for lizard 5 multitenancy.
    if 'host' in options:
        set_host(options['host'])

    for ds in datasource.datasources_from_entrypoints():
        try:
            scripts.cache_latest_values(ds)
        except:
            logger.exception('skipping datasource {0}'.format(ds))
示例#5
0
    def test_import_error_is_ignored(self):
        entrypoint1 = mock.MagicMock()
        factory1 = mock.MagicMock(return_value=["whee"])
        entrypoint1.load = mock.MagicMock(return_value=factory1)

        entrypoint2 = mock.MagicMock()

        def raises_import_error():
            raise ImportError()

        entrypoint2.load = raises_import_error

        with mock.patch(
            'lizard_datasource.datasource.datasource_entrypoints',
            return_value=[entrypoint1, entrypoint2]):
            self.assertEquals(
                datasource.datasources_from_entrypoints(),
                ["whee"])
 def handle(self, *args, **options):
     for ds in datasource.datasources_from_entrypoints():
         print(ds)
         scripts.cache_latest_values(ds)