예제 #1
0
 def GetAccessKey( self, session_key ):
     
     with self._lock:
         
         if session_key not in self._session_keys_to_access_keys_and_expirys:
             
             raise HydrusExceptions.DataMissing( 'Did not find an entry for that session key!' )
             
         
         ( access_key, session_expiry ) = self._session_keys_to_access_keys_and_expirys[ session_key ]
         
         if HydrusData.TimeHasPassed( session_expiry ):
             
             del self._session_keys_to_access_keys_and_expirys[ session_expiry ]
             
             raise HydrusExceptions.SessionException( 'That session key has expired!' )
             
         
         self._session_keys_to_access_keys_and_expirys[ session_key ] = ( access_key, HydrusData.GetNow() + SESSION_EXPIRY )
         
     
     return access_key
예제 #2
0
 def GetAccount( self, service_key, session_key ):
     
     with self._lock:
         
         session_keys_to_sessions = self._service_keys_to_session_keys_to_sessions[ service_key ]
         
         if session_key in session_keys_to_sessions:
             
             ( account_key, expires ) = session_keys_to_sessions[ session_key ]
             
             if HydrusData.TimeHasPassed( expires ):
                 
                 del session_keys_to_sessions[ session_key ]
                 
             else:
                 
                 account = self._service_keys_to_account_keys_to_accounts[ service_key ][ account_key ]
                 
                 return account
                 
             
         
         raise HydrusExceptions.SessionException( 'Did not find that session! Try again!' )