<s> import collections <EOL> import datetime <EOL> import redis <EOL> from django . conf import settings <EOL> from django . utils . timezone import utc <EOL> from admin_tools . dashboard . modules import DashboardModule <EOL> class StatusModule ( DashboardModule ) : <EOL> title = "<STR_LIT>" <EOL> template = "<STR_LIT>" <EOL> def init_with_context ( self , context ) : <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> datastore = redis . StrictRedis ( ** dict ( [ ( x . lower ( ) , y ) for x , y in settings . REDIS [ settings . PYPI_DATASTORE ] . items ( ) ] ) ) <EOL> if datastore . get ( "<STR_LIT>" ) is not None : <EOL> self . last_sync = datetime . datetime . fromtimestamp ( float ( datastore . get ( "<STR_LIT>" ) ) ) <EOL> self . last_sync . replace ( tzinfo = utc ) <EOL> else : <EOL> self . last_sync = None <EOL> self . celery_queue_length = datastore . llen ( "<STR_LIT>" ) <EOL> def is_empty ( self ) : <EOL> return False <EOL> class RedisStatusModule ( DashboardModule ) : <EOL> title = "<STR_LIT>" <EOL> template = "<STR_LIT>" <EOL> def init_with_context ( self , context ) : <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> datastore = redis . StrictRedis ( ** dict ( [ ( x . lower ( ) , y ) for x , y in settings . REDIS [ settings . PYPI_DATASTORE ] . items ( ) ] ) ) <EOL> self . redis_info = collections . OrderedDict ( sorted ( [ ( k , v ) for k , v in datastore . info ( ) . iteritems ( ) ] , key = lambda x : x [ <NUM_LIT:0> ] ) ) <EOL> def is_empty ( self ) : <EOL> return False </s>
