<s> import cPickle as pickle <EOL> import re <EOL> from hashlib import md5 <EOL> from jasmin . protocols . cli . managers import PersistableManager , Session <EOL> from jasmin . protocols . cli . protocol import str2num <EOL> from jasmin . routing . jasminApi import User , MtMessagingCredential , SmppsCredential , jasminApiCredentialError <EOL> MtMessagingCredentialKeyMap = { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:content>' : '<STR_LIT:content>' } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } } <EOL> SmppsCredentialKeyMap = { '<STR_LIT:class>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } <EOL> UserKeyMap = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:username>' : '<STR_LIT:username>' , <EOL> '<STR_LIT:password>' : '<STR_LIT:password>' , <EOL> '<STR_LIT>' : MtMessagingCredentialKeyMap , <EOL> '<STR_LIT>' : SmppsCredentialKeyMap } <EOL> UserConfigStringKeys = [ '<STR_LIT:username>' , '<STR_LIT:password>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> TrueBoolCastMap = [ '<STR_LIT:true>' , '<STR_LIT:1>' , '<STR_LIT:t>' , '<STR_LIT:y>' , '<STR_LIT:yes>' ] <EOL> FalseBoolCastMap = [ '<STR_LIT:false>' , '<STR_LIT:0>' , '<STR_LIT:f>' , '<STR_LIT:n>' , '<STR_LIT>' ] <EOL> def castToBuiltCorrectCredType ( cred , section , key , value , update = False ) : <EOL> '<STR_LIT>' <EOL> keep_original_value = None <EOL> if cred == '<STR_LIT>' : <EOL> if section == '<STR_LIT>' : <EOL> if value . lower ( ) in TrueBoolCastMap : <EOL> value = True <EOL> elif value . lower ( ) in FalseBoolCastMap : <EOL> value = False <EOL> elif section == '<STR_LIT>' : <EOL> if value . lower ( ) == '<STR_LIT:none>' : <EOL> value = None <EOL> elif update and value [ : <NUM_LIT:1> ] in [ '<STR_LIT:+>' , '<STR_LIT:->' ] : <EOL> if ( key in [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) : <EOL> keep_original_value = float ( value ) <EOL> if keep_original_value > <NUM_LIT:0> : <EOL> keep_original_value = '<STR_LIT>' % float ( value ) <EOL> value = abs ( float ( value ) ) <EOL> elif key == '<STR_LIT>' : <EOL> keep_original_value = int ( value ) <EOL> if keep_original_value > <NUM_LIT:0> : <EOL> keep_original_value = '<STR_LIT>' % int ( value ) <EOL> value = abs ( int ( value ) ) <EOL> elif ( key in [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) : <EOL> value = float ( value ) <EOL> elif key == '<STR_LIT>' : <EOL> value = int ( value ) <EOL> _o = MtMessagingCredential ( ) <EOL> getattr ( _o , '<STR_LIT>' % section ) ( key , value ) <EOL> elif cred == '<STR_LIT>' : <EOL> if section == '<STR_LIT>' : <EOL> if value . lower ( ) in TrueBoolCastMap : <EOL> value = True <EOL> elif value . lower ( ) in FalseBoolCastMap : <EOL> value = False <EOL> elif section == '<STR_LIT>' : <EOL> if value . lower ( ) == '<STR_LIT:none>' : <EOL> value = None <EOL> elif update and value [ : <NUM_LIT:1> ] in [ '<STR_LIT:+>' , '<STR_LIT:->' ] : <EOL> if key == '<STR_LIT>' : <EOL> keep_original_value = int ( value ) <EOL> if keep_original_value > <NUM_LIT:0> : <EOL> keep_original_value = '<STR_LIT>' % int ( value ) <EOL> value = abs ( int ( value ) ) <EOL> elif key == '<STR_LIT>' : <EOL> value = int ( value ) <EOL> _o = SmppsCredential ( ) <EOL> getattr ( _o , '<STR_LIT>' % section ) ( key , value ) <EOL> if keep_original_value is not None : <EOL> return keep_original_value <EOL> else : <EOL> return value <EOL> def UserBuild ( fCallback ) : <EOL> '<STR_LIT>' <EOL> def parse_args_and_call_with_instance ( self , * args , ** kwargs ) : <EOL> cmd = args [ <NUM_LIT:0> ] <EOL> arg = args [ <NUM_LIT:1> ] <EOL> if cmd is None : <EOL> return self . protocol . sendData ( ) <EOL> if cmd == '<STR_LIT>' : <EOL> if ( '<STR_LIT>' not in self . sessBuffer or <EOL> '<STR_LIT>' not in self . sessBuffer or <EOL> '<STR_LIT:username>' not in self . sessBuffer or <EOL> '<STR_LIT:password>' not in self . sessBuffer ) : <EOL> return self . protocol . sendData ( <EOL> '<STR_LIT>' ) <EOL> if '<STR_LIT>' not in self . sessBuffer : <EOL> self . sessBuffer [ UserKeyMap [ '<STR_LIT>' ] [ '<STR_LIT>' ] ] = globals ( ) [ <EOL> UserKeyMap [ '<STR_LIT>' ] [ '<STR_LIT:class>' ] ] ( ) <EOL> if '<STR_LIT>' not in self . sessBuffer : <EOL> self . sessBuffer [ UserKeyMap [ '<STR_LIT>' ] [ '<STR_LIT>' ] ] = globals ( ) [ <EOL> UserKeyMap [ '<STR_LIT>' ] [ '<STR_LIT:class>' ] ] ( ) <EOL> user = { } <EOL> for key , value in self . sessBuffer . iteritems ( ) : <EOL> user [ key ] = value <EOL> try : <EOL> UserInstance = User ( ** user ) <EOL> return fCallback ( self , UserInstance ) <EOL> except Exception , e : <EOL> return self . protocol . sendData ( '<STR_LIT>' % str ( e ) ) <EOL> else : <EOL> if cmd not in UserKeyMap : <EOL> return self . protocol . sendData ( '<STR_LIT>' % cmd ) <EOL> if isinstance ( UserKeyMap [ cmd ] , dict ) : <EOL> subKeyMap = UserKeyMap [ cmd ] <EOL> _r = re . match ( r'<STR_LIT>' , arg ) <EOL> if not _r : <EOL> return self . protocol . sendData ( '<STR_LIT>' % cmd ) <EOL> section = _r . group ( <NUM_LIT:1> ) . lower ( ) <EOL> key = _r . group ( <NUM_LIT:2> ) . lower ( ) <EOL> value = _r . group ( <NUM_LIT:3> ) <EOL> possible_values = subKeyMap . keys ( ) <EOL> possible_values . remove ( '<STR_LIT:class>' ) <EOL> possible_values . remove ( '<STR_LIT>' ) <EOL> valid_section = False <EOL> for pv in possible_values : <EOL> if section == pv . lower ( ) : <EOL> section = pv <EOL> valid_section = True <EOL> break <EOL> if not valid_section : <EOL> return self . protocol . sendData ( '<STR_LIT>' % ( <EOL> section , '<STR_LIT:U+002CU+0020>' . join ( possible_values ) ) ) <EOL> if key not in subKeyMap [ section ] . keys ( ) : <EOL> return self . protocol . sendData ( '<STR_LIT>' % ( <EOL> key , '<STR_LIT:U+002CU+0020>' . join ( subKeyMap [ section ] . keys ( ) ) ) ) <EOL> SectionKey = subKeyMap [ section ] [ key ] <EOL> try : <EOL> SectionValue = castToBuiltCorrectCredType ( subKeyMap [ '<STR_LIT:class>' ] , section , SectionKey , value ) <EOL> if subKeyMap [ '<STR_LIT>' ] not in self . sessBuffer : <EOL> self . sessBuffer [ subKeyMap [ '<STR_LIT>' ] ] = globals ( ) [ subKeyMap [ '<STR_LIT:class>' ] ] ( ) <EOL> getattr ( self . sessBuffer [ subKeyMap [ '<STR_LIT>' ] ] , '<STR_LIT>' % section ) ( <EOL> SectionKey , SectionValue ) <EOL> except ( jasminApiCredentialError , ValueError ) as e : <EOL> return self . protocol . sendData ( '<STR_LIT>' % str ( e ) ) <EOL> else : <EOL> if cmd == '<STR_LIT>' : <EOL> group = self . pb [ '<STR_LIT>' ] . getGroup ( arg ) <EOL> if group is None : <EOL> return self . protocol . sendData ( <EOL> '<STR_LIT>' % arg ) <EOL> self . sessBuffer [ '<STR_LIT>' ] = group <EOL> else : <EOL> UserKey = UserKeyMap [ cmd ] <EOL> if UserKey not in UserConfigStringKeys : <EOL> self . sessBuffer [ UserKey ] = str2num ( arg ) <EOL> else : <EOL> self . sessBuffer [ UserKey ] = arg <EOL> return self . protocol . sendData ( ) <EOL> return parse_args_and_call_with_instance <EOL> class UserExist ( object ) : <EOL> '<STR_LIT>' <EOL> def __init__ ( self , uid_key ) : <EOL> self . uid_key = uid_key <EOL> def __call__ ( self , fCallback ) : <EOL> uid_key = self . uid_key <EOL> def exist_user_and_call ( self , * args , ** kwargs ) : <EOL> opts = args [ <NUM_LIT:1> ] <EOL> uid = getattr ( opts , uid_key ) <EOL> if self . pb [ '<STR_LIT>' ] . getUser ( uid ) is not None : <EOL> return fCallback ( self , * args , ** kwargs ) <EOL> return self . protocol . sendData ( '<STR_LIT>' % uid ) <EOL> return exist_user_and_call <EOL> def UserUpdate ( fCallback ) : <EOL> '''<STR_LIT>''' <EOL> def log_update_requests_and_call ( self , * args , ** kwargs ) : <EOL> cmd = args [ <NUM_LIT:0> ] <EOL> arg = args [ <NUM_LIT:1> ] <EOL> if cmd is None : <EOL> return self . protocol . sendData ( ) <EOL> if cmd == '<STR_LIT>' : <EOL> if len ( self . sessBuffer ) == <NUM_LIT:0> : <EOL> return self . protocol . sendData ( '<STR_LIT>' ) <EOL> return fCallback ( self , self . sessBuffer ) <EOL> else : <EOL> if cmd not in UserKeyMap : <EOL> return self . protocol . sendData ( '<STR_LIT>' % cmd ) <EOL> if cmd == '<STR_LIT>' : <EOL> return self . protocol . sendData ( '<STR_LIT>' ) <EOL> if cmd == '<STR_LIT:username>' : <EOL> return self . protocol . sendData ( '<STR_LIT>' ) <EOL> if isinstance ( UserKeyMap [ cmd ] , dict ) : <EOL> subKeyMap = UserKeyMap [ cmd ] <EOL> _r = re . match ( r'<STR_LIT>' , arg ) <EOL> if not _r : <EOL> return self . protocol . sendData ( '<STR_LIT>' % cmd ) <EOL> section = _r . group ( <NUM_LIT:1> ) . lower ( ) <EOL> key = _r . group ( <NUM_LIT:2> ) . lower ( ) <EOL> value = _r . group ( <NUM_LIT:3> ) <EOL> possible_values = subKeyMap . keys ( ) <EOL> possible_values . remove ( '<STR_LIT:class>' ) <EOL> possible_values . remove ( '<STR_LIT>' ) <EOL> valid_section = False <EOL> for pv in possible_values : <EOL> if section == pv . lower ( ) : <EOL> section = pv <EOL> valid_section = True <EOL> break <EOL> if not valid_section : <EOL> return self . protocol . sendData ( '<STR_LIT>' % ( <EOL> section , '<STR_LIT:U+002CU+0020>' . join ( possible_values ) ) ) <EOL> if key not in subKeyMap [ section ] . keys ( ) : <EOL> return self . protocol . sendData ( '<STR_LIT>' % ( <EOL> key , '<STR_LIT:U+002CU+0020>' . join ( subKeyMap [ section ] . keys ( ) ) ) ) <EOL> SectionKey = subKeyMap [ section ] [ key ] <EOL> try : <EOL> SectionValue = castToBuiltCorrectCredType ( <EOL> subKeyMap [ '<STR_LIT:class>' ] , section , SectionKey , value , update = True ) <EOL> sessBufferKey = '<STR_LIT>' % subKeyMap [ '<STR_LIT>' ] <EOL> if sessBufferKey not in self . sessBuffer : <EOL> self . sessBuffer [ sessBufferKey ] = { section : { } } <EOL> if section not in self . sessBuffer [ sessBufferKey ] : <EOL> self . sessBuffer [ sessBufferKey ] [ section ] = { } <EOL> self . sessBuffer [ sessBufferKey ] [ section ] [ SectionKey ] = SectionValue <EOL> except ( jasminApiCredentialError , ValueError ) as e : <EOL> return self . protocol . sendData ( '<STR_LIT>' % str ( e ) ) <EOL> else : <EOL> if cmd == '<STR_LIT>' : <EOL> group = self . pb [ '<STR_LIT>' ] . getGroup ( arg ) <EOL> if group is None : <EOL> return self . protocol . sendData ( <EOL> '<STR_LIT>' % arg ) <EOL> self . sessBuffer [ '<STR_LIT>' ] = group <EOL> else : <EOL> UserKey = UserKeyMap [ cmd ] <EOL> if UserKey not in UserConfigStringKeys : <EOL> self . sessBuffer [ UserKey ] = str2num ( arg ) <EOL> else : <EOL> self . sessBuffer [ UserKey ] = arg <EOL> return self . protocol . sendData ( ) <EOL> return log_update_requests_and_call <EOL> class UsersManager ( PersistableManager ) : <EOL> "<STR_LIT>" <EOL> managerName = '<STR_LIT:user>' <EOL> def persist ( self , arg , opts ) : <EOL> if self . pb [ '<STR_LIT>' ] . perspective_persist ( opts . profile , '<STR_LIT>' ) : <EOL> self . protocol . sendData ( <EOL> '<STR_LIT>' % ( self . managerName , opts . profile ) , <EOL> prompt = False ) <EOL> else : <EOL> self . protocol . sendData ( <EOL> '<STR_LIT>' % ( self . managerName , opts . profile ) , <EOL> prompt = False ) <EOL> def load ( self , arg , opts ) : <EOL> r = self . pb [ '<STR_LIT>' ] . perspective_load ( opts . profile , '<STR_LIT>' ) <EOL> if r : <EOL> self . protocol . sendData ( <EOL> '<STR_LIT>' % ( self . managerName , opts . profile ) , <EOL> prompt = False ) <EOL> else : <EOL> self . protocol . sendData ( <EOL> '<STR_LIT>' % ( self . managerName , opts . profile ) , <EOL> prompt = False ) <EOL> def list ( self , arg , opts ) : <EOL> if arg != '<STR_LIT>' : <EOL> gid = arg <EOL> else : <EOL> gid = None <EOL> users = pickle . loads ( self . pb [ '<STR_LIT>' ] . perspective_user_get_all ( gid ) ) <EOL> counter = <NUM_LIT:0> <EOL> if ( len ( users ) ) > <NUM_LIT:0> : <EOL> self . protocol . sendData ( "<STR_LIT>" % ( <EOL> '<STR_LIT>' . ljust ( <NUM_LIT:16> ) , <EOL> '<STR_LIT>' . ljust ( <NUM_LIT:16> ) , <EOL> '<STR_LIT>' . ljust ( <NUM_LIT:16> ) , <EOL> '<STR_LIT>' . ljust ( <NUM_LIT:7> ) , <EOL> '<STR_LIT>' . ljust ( <NUM_LIT:6> ) , <EOL> '<STR_LIT>' . ljust ( <NUM_LIT:8> ) ) , prompt = False ) <EOL> for user in users : <EOL> counter += <NUM_LIT:1> <EOL> user_prefix = '<STR_LIT>' <EOL> if not user . enabled : <EOL> user_prefix = '<STR_LIT:!>' <EOL> group_prefix = '<STR_LIT>' <EOL> group = self . pb [ '<STR_LIT>' ] . getGroup ( user . group . gid ) <EOL> if group is not None and not group . enabled : <EOL> group_prefix = '<STR_LIT:!>' <EOL> balance = user . mt_credential . getQuota ( '<STR_LIT>' ) <EOL> if balance is None : <EOL> balance = '<STR_LIT>' <EOL> sms_count = user . mt_credential . getQuota ( '<STR_LIT>' ) <EOL> if sms_count is None : <EOL> sms_count = '<STR_LIT>' <EOL> if balance == '<STR_LIT>' and sms_count == '<STR_LIT>' : <EOL> balance = '<STR_LIT>' <EOL> sms_count = '<STR_LIT>' <EOL> http_throughput = user . mt_credential . getQuota ( '<STR_LIT>' ) <EOL> if http_throughput is None : <EOL> http_throughput = '<STR_LIT>' <EOL> smpps_throughput = user . mt_credential . getQuota ( '<STR_LIT>' ) <EOL> if smpps_throughput is None : <EOL> smpps_throughput = '<STR_LIT>' <EOL> throughput = '<STR_LIT>' % ( http_throughput , smpps_throughput ) <EOL> self . protocol . sendData ( "<STR_LIT>" % ( <EOL> str ( user_prefix + user . uid ) . ljust ( <NUM_LIT:16> ) , <EOL> str ( group_prefix + user . group . gid ) . ljust ( <NUM_LIT:16> ) , <EOL> str ( user . username ) . ljust ( <NUM_LIT:16> ) , <EOL> str ( balance ) . ljust ( <NUM_LIT:7> ) , <EOL> str ( sms_count ) . ljust ( <NUM_LIT:6> ) , <EOL> str ( throughput ) . ljust ( <NUM_LIT:8> ) ) , prompt = False ) <EOL> self . protocol . sendData ( prompt = False ) <EOL> if gid is None : <EOL> self . protocol . sendData ( '<STR_LIT>' % counter ) <EOL> else : <EOL> self . protocol . sendData ( '<STR_LIT>' % ( gid , counter ) ) <EOL> @ Session <EOL> @ UserBuild <EOL> def add_session ( self , UserInstance ) : <EOL> st = self . pb [ '<STR_LIT>' ] . perspective_user_add ( pickle . dumps ( UserInstance , pickle . HIGHEST_PROTOCOL ) ) <EOL> if st : <EOL> self . protocol . sendData ( <EOL> '<STR_LIT>' % ( UserInstance . uid , UserInstance . group . gid ) , <EOL> prompt = False ) <EOL> self . stopSession ( ) <EOL> else : <EOL> self . protocol . sendData ( '<STR_LIT>' ) <EOL> def add ( self , arg , opts ) : <EOL> return self . startSession ( self . add_session , <EOL> annoucement = '<STR_LIT>' , <EOL> completitions = UserKeyMap . keys ( ) ) <EOL> @ UserExist ( uid_key = '<STR_LIT>' ) <EOL> def enable ( self , arg , opts ) : <EOL> st = self . pb [ '<STR_LIT>' ] . perspective_user_enable ( opts . enable ) <EOL> if st : <EOL> self . protocol . sendData ( '<STR_LIT>' % opts . enable ) <EOL> else : <EOL> self . protocol . sendData ( '<STR_LIT>' ) <EOL> @ UserExist ( uid_key = '<STR_LIT>' ) <EOL> def disable ( self , arg , opts ) : <EOL> st = self . pb [ '<STR_LIT>' ] . perspective_user_disable ( opts . disable ) <EOL> if st : <EOL> self . protocol . sendData ( '<STR_LIT>' % opts . disable ) <EOL> else : <EOL> self . protocol . sendData ( '<STR_LIT>' ) <EOL> @ Session <EOL> @ UserUpdate <EOL> def update_session ( self , updateLog ) : <EOL> user = self . pb [ '<STR_LIT>' ] . getUser ( self . sessionContext [ '<STR_LIT>' ] ) <EOL> for key , value in updateLog . iteritems ( ) : <EOL> if key [ : <NUM_LIT:1> ] == '<STR_LIT:_>' : <EOL> subUserObject = getattr ( user , key [ <NUM_LIT:1> : ] ) <EOL> for update in value . iteritems ( ) : <EOL> section = update [ <NUM_LIT:0> ] <EOL> if update [ <NUM_LIT:1> ] is None : <EOL> continue <EOL> for SectionKey , SectionValue in update [ <NUM_LIT:1> ] . iteritems ( ) : <EOL> if str ( SectionValue ) [ : <NUM_LIT:1> ] in [ '<STR_LIT:+>' , '<STR_LIT:->' ] : <EOL> if str ( SectionValue ) [ : <NUM_LIT:1> ] == '<STR_LIT:+>' : <EOL> if str ( SectionValue ) [ <NUM_LIT:1> : <NUM_LIT:2> ] == '<STR_LIT:f>' : <EOL> getattr ( subUserObject , '<STR_LIT>' % section ) ( <EOL> SectionKey , float ( SectionValue [ <NUM_LIT:2> : ] ) ) <EOL> elif str ( SectionValue ) [ <NUM_LIT:1> : <NUM_LIT:2> ] == '<STR_LIT:i>' : <EOL> getattr ( subUserObject , '<STR_LIT>' % section ) ( <EOL> SectionKey , int ( SectionValue [ <NUM_LIT:2> : ] ) ) <EOL> else : <EOL> getattr ( subUserObject , '<STR_LIT>' % section ) ( SectionKey , SectionValue ) <EOL> else : <EOL> try : <EOL> getattr ( subUserObject , '<STR_LIT>' % section ) ( SectionKey , SectionValue ) <EOL> except jasminApiCredentialError : <EOL> self . protocol . sendData ( <EOL> '<STR_LIT>' % SectionKey , <EOL> prompt = False ) <EOL> else : <EOL> if key == '<STR_LIT:password>' : <EOL> setattr ( user , key , md5 ( value ) . digest ( ) ) <EOL> else : <EOL> setattr ( user , key , value ) <EOL> self . protocol . sendData ( '<STR_LIT>' % self . sessionContext [ '<STR_LIT>' ] , prompt = False ) <EOL> self . stopSession ( ) <EOL> @ UserExist ( uid_key = '<STR_LIT>' ) <EOL> def update ( self , arg , opts ) : <EOL> return self . startSession ( self . update_session , <EOL> annoucement = '<STR_LIT>' % opts . update , <EOL> completitions = UserKeyMap . keys ( ) , <EOL> sessionContext = { '<STR_LIT>' : opts . update } ) <EOL> @ UserExist ( uid_key = '<STR_LIT>' ) <EOL> def remove ( self , arg , opts ) : <EOL> st = self . pb [ '<STR_LIT>' ] . perspective_user_remove ( opts . remove ) <EOL> if st : <EOL> self . protocol . sendData ( '<STR_LIT>' % opts . remove ) <EOL> else : <EOL> self . protocol . sendData ( '<STR_LIT>' ) <EOL> @ UserExist ( uid_key = '<STR_LIT>' ) <EOL> def show ( self , arg , opts ) : <EOL> user = self . pb [ '<STR_LIT>' ] . getUser ( opts . show ) <EOL> for key , value in UserKeyMap . iteritems ( ) : <EOL> if key == '<STR_LIT:password>' : <EOL> pass <EOL> elif key == '<STR_LIT>' : <EOL> self . protocol . sendData ( '<STR_LIT>' % ( user . group . gid ) , prompt = False ) <EOL> elif isinstance ( value , str ) : <EOL> self . protocol . sendData ( '<STR_LIT>' % ( key , getattr ( user , value ) ) , prompt = False ) <EOL> elif isinstance ( value , dict ) and '<STR_LIT:class>' in value : <EOL> if value [ '<STR_LIT:class>' ] == '<STR_LIT>' : <EOL> for section , sectionData in value . iteritems ( ) : <EOL> if section in [ '<STR_LIT:class>' , '<STR_LIT>' ] : <EOL> continue <EOL> for SectionShortKey , SectionLongKey in value [ section ] . iteritems ( ) : <EOL> try : <EOL> sectionValue = getattr ( user . mt_credential , '<STR_LIT>' % section ) ( SectionLongKey ) <EOL> except jasminApiCredentialError : <EOL> sectionValue = '<STR_LIT>' <EOL> if section == '<STR_LIT>' : <EOL> sectionValue = sectionValue . pattern <EOL> elif section == '<STR_LIT>' and sectionValue is None : <EOL> sectionValue = '<STR_LIT>' <EOL> self . protocol . sendData ( '<STR_LIT>' % ( <EOL> key , section . lower ( ) , SectionShortKey , sectionValue ) , prompt = False ) <EOL> if value [ '<STR_LIT:class>' ] == '<STR_LIT>' : <EOL> for section , sectionData in value . iteritems ( ) : <EOL> if section in [ '<STR_LIT:class>' , '<STR_LIT>' ] : <EOL> continue <EOL> for SectionShortKey , SectionLongKey in value [ section ] . iteritems ( ) : <EOL> sectionValue = getattr ( user . smpps_credential , '<STR_LIT>' % section ) ( SectionLongKey ) <EOL> if section == '<STR_LIT>' : <EOL> sectionValue = sectionValue . pattern <EOL> elif section == '<STR_LIT>' and sectionValue is None : <EOL> sectionValue = '<STR_LIT>' <EOL> self . protocol . sendData ( '<STR_LIT>' % ( <EOL> key , section . lower ( ) , SectionShortKey , sectionValue ) , prompt = False ) <EOL> self . protocol . sendData ( ) <EOL> @ UserExist ( uid_key = '<STR_LIT>' ) <EOL> def unbind ( self , arg , opts ) : <EOL> user = self . pb [ '<STR_LIT>' ] . getUser ( opts . smpp_unbind ) <EOL> st = self . pb [ '<STR_LIT>' ] . unbindAndRemoveGateway ( user , ban = False ) <EOL> if st : <EOL> self . protocol . sendData ( '<STR_LIT>' % opts . smpp_unbind ) <EOL> else : <EOL> self . protocol . sendData ( '<STR_LIT>' ) <EOL> @ UserExist ( uid_key = '<STR_LIT>' ) <EOL> def ban ( self , arg , opts ) : <EOL> user = self . pb [ '<STR_LIT>' ] . getUser ( opts . smpp_ban ) <EOL> st = self . pb [ '<STR_LIT>' ] . unbindAndRemoveGateway ( user ) <EOL> if st : <EOL> self . protocol . sendData ( '<STR_LIT>' % opts . smpp_ban ) <EOL> else : <EOL> self . protocol . sendData ( '<STR_LIT>' ) </s>
