示例#1
0
 def _load_authnz_wrapper(self):
     authnz_wrapper_class_name = self.config.get('AUTHNZ_WRAPPER', None)
     if authnz_wrapper_class_name:
         authnz_wrapper_list = load_classes(default=[authnz_wrapper_class_name])
         if isinstance(authnz_wrapper_list, list) and len(authnz_wrapper_list) == 1:
             return authnz_wrapper_list.pop()
     return None
示例#2
0
 def load_authnz_wrapper(self):
     authnz_wrapper_class_name = self.config.get('AUTHNZ_WRAPPER', None)
     if authnz_wrapper_class_name:
         authnz_wrapper_list = load_classes(
             default=[authnz_wrapper_class_name])
         if isinstance(authnz_wrapper_list,
                       list) and len(authnz_wrapper_list) == 1:
             return authnz_wrapper_list.pop()
     return None
示例#3
0
    def new_instance(cls, config):
        authnz_wrapper_list = load_classes(default=[config.AUTHNZ_WRAPPER])
        if isinstance(authnz_wrapper_list, list) and len(authnz_wrapper_list) == 1:
            authnz_wrapper_class = authnz_wrapper_list.pop()
        else:
            raise Exception('An authentication/authorization wrapper must be defined!')

        authnz_wrapper = authnz_wrapper_class(config)

        return AuthNZElasticSearchProvider(
            config=config,
            authnz_wrapper=authnz_wrapper
        )
示例#4
0
    def new_instance(cls, config):
        authnz_wrapper_list = load_classes(default=[config.AUTHNZ_WRAPPER])
        if isinstance(authnz_wrapper_list,
                      list) and len(authnz_wrapper_list) == 1:
            authnz_wrapper_class = authnz_wrapper_list.pop()
        else:
            raise Exception(
                'An authentication/authorization wrapper must be defined!')

        authnz_wrapper = authnz_wrapper_class(config)

        return AuthNZElasticSearchProvider(config=config,
                                           authnz_wrapper=authnz_wrapper)
示例#5
0
    def test_can_load_classes(self):
        from holmes.models.domain import Domain
        from holmes.models.page import Page
        from holmes.models.review import Review

        classes = load_classes(default=[
            'holmes.models.domain.Domain',
            'holmes.models.page.Page',
            'holmes.models.review.Review',
        ])

        expect(classes).to_length(3)
        expect(classes[0]).to_equal(Domain)
        expect(classes[1]).to_equal(Page)
        expect(classes[2]).to_equal(Review)
示例#6
0
def main():
    parser = SearchProvider.argparser()
    args = parser.parse_args()
    try:
        config = Config()
        if args.conf:
            config = config.load(args.conf[0])
        search_providers = load_classes(default=[config['SEARCH_PROVIDER']])
        if isinstance(search_providers, list) and len(search_providers) == 1:
            search_provider = search_providers.pop()
            search_provider.main()
        else:
            logging.error('Could not instantiate search provider!')
            sys.exit(1)
    except ConfigurationError:
        logging.error('Could not load config! Use --conf conf_file')
        sys.exit(1)
    except KeyError:
        logging.error('Could not parse config! Check it\'s contents')
        sys.exit(1)
示例#7
0
def main():
    parser = SearchProvider.argparser()
    args = parser.parse_args()
    try:
        config = Config()
        if args.conf:
            config = config.load(args.conf[0])
        search_providers = load_classes(default=[config['SEARCH_PROVIDER']])
        if isinstance(search_providers, list) and len(search_providers) == 1:
            search_provider = search_providers.pop()
            search_provider.main()
        else:
            logging.error('Could not instantiate search provider!')
            sys.exit(1)
    except ConfigurationError:
        logging.error('Could not load config! Use --conf conf_file')
        sys.exit(1)
    except KeyError:
        logging.error('Could not parse config! Check it\'s contents')
        sys.exit(1)
示例#8
0
 def _load_facters(self):
     return load_classes(default=self.config.FACTERS)
示例#9
0
 def _load_validators(self):
     return load_classes(default=self.config.VALIDATORS)
示例#10
0
 def load_search_provider(self):
     search_provider = load_classes(default=[self.config.SEARCH_PROVIDER])
     if isinstance(search_provider, list) and len(search_provider) == 1:
         return search_provider.pop()
     else:
         raise Exception('A search provider must be defined!')
示例#11
0
 def load_error_handlers(self):
     return load_classes(default=self.config.ERROR_HANDLERS)
示例#12
0
 def load_error_handlers(self):
     return load_classes(default=self.config.ERROR_HANDLERS)
示例#13
0
 def _load_search_provider(self):
     search_provider = load_classes(default=[self.config.SEARCH_PROVIDER])
     if isinstance(search_provider, list) and len(search_provider) == 1:
         return search_provider.pop()
     else:
         raise Exception('A search provider must be defined!')
示例#14
0
 def _load_facters(self):
     return load_classes(default=self.config.FACTERS)
示例#15
0
 def _load_validators(self):
     return load_classes(default=self.config.VALIDATORS)