<s> import os <EOL> import glob <EOL> import logging <EOL> from django . conf import settings <EOL> try : <EOL> set <EOL> except NameError : <EOL> from sets import Set as set <EOL> log = logging . getLogger ( "<STR_LIT>" ) <EOL> def active_providers ( ) : <EOL> """<STR_LIT>""" <EOL> providers = { } <EOL> for provider in settings . JELLYROLL_PROVIDERS : <EOL> if provider . endswith ( '<STR_LIT>' ) : <EOL> to_load = expand_star ( provider ) <EOL> else : <EOL> to_load = [ provider ] <EOL> for p in to_load : <EOL> try : <EOL> mod = __import__ ( p , '<STR_LIT>' , '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> except ImportError , e : <EOL> log . error ( "<STR_LIT>" % ( p , e ) ) <EOL> if mod . enabled ( ) : <EOL> providers [ p ] = mod <EOL> return providers <EOL> def expand_star ( mod_name ) : <EOL> """<STR_LIT>""" <EOL> expanded = [ ] <EOL> mod_dir = os . path . dirname ( __import__ ( mod_name [ : - <NUM_LIT:2> ] , { } , { } , [ '<STR_LIT>' ] ) . __file__ ) <EOL> for f in glob . glob1 ( mod_dir , "<STR_LIT>" ) : <EOL> expanded . append ( '<STR_LIT>' % ( mod_name [ : - <NUM_LIT:2> ] , f [ : - <NUM_LIT:3> ] ) ) <EOL> return expanded <EOL> def update ( providers ) : <EOL> """<STR_LIT>""" <EOL> active = active_providers ( ) <EOL> if providers is None : <EOL> providers = active . keys ( ) <EOL> else : <EOL> providers = set ( active . keys ( ) ) . intersection ( providers ) <EOL> for provider in providers : <EOL> log . debug ( "<STR_LIT>" , provider ) <EOL> try : <EOL> mod = active [ provider ] <EOL> except KeyError : <EOL> log . error ( "<STR_LIT>" % provider ) <EOL> continue <EOL> log . info ( "<STR_LIT>" , provider ) <EOL> try : <EOL> mod . update ( ) <EOL> except ( KeyboardInterrupt , SystemExit ) : <EOL> raise <EOL> except Exception , e : <EOL> log . error ( "<STR_LIT>" , provider ) <EOL> log . exception ( e ) <EOL> continue <EOL> log . info ( "<STR_LIT>" , provider ) </s>
