#NEWLINE# def action_redis_server_disconnect( config ) : #NEWLINE# #INDENT# '\n\tDisconnect one or more users from server\n\t' #NEWLINE# log . warning ( '  - Trying to connect with redis server...' ) #NEWLINE# con = redis . StrictRedis ( host = config . target , port = config . port , db = config . db ) #NEWLINE# clients = { x [ 'addr' ] : x [ 'addr' ] for x in con . client_list ( ) } #NEWLINE# if config . disconnect_all : #NEWLINE# #INDENT# for c in clients : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# con . client_kill ( c ) #NEWLINE# log . error ( ( "  - Client '%s' was disconnected" % c ) ) #NEWLINE# #UNINDENT# except redis . exceptions . ResponseError : #NEWLINE# #INDENT# log . error ( ( "  - Client '%s' is not connected" % c ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( config . client is None ) or ( ':' not in config . client ) ) : #NEWLINE# #INDENT# log . error ( '  <!> Invalid client format. Client must be format: IP:PORT, i.e: 10.211.55.2:61864' ) #NEWLINE# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# _c = clients [ config . client ] #NEWLINE# try : #NEWLINE# #INDENT# con . client_kill ( _c ) #NEWLINE# log . error ( ( "  - Client '%s' was disconnected" % _c ) ) #NEWLINE# #UNINDENT# except redis . exceptions . ResponseError : #NEWLINE# #INDENT# log . error ( ( "  - Client '%s' is not connected" % _c ) ) #NEWLINE# #UNINDENT# #UNINDENT# except KeyError : #NEWLINE# #INDENT# log . error ( ( "  <!> Client '%s' doesn't appear to be connected to server" % config . client ) )