def _checkService( self, request ): if self.BLOCKED_WHEN_BUSY and HG.server_busy.locked(): raise HydrusExceptions.ServerBusyException( 'This server is busy, please try again later.' ) return request
def _GetAccountKeyFromAccessKey( self, service_key, access_key ): hashed_access_key = hashlib.sha256( access_key ).digest() if hashed_access_key not in self._service_keys_to_hashed_access_keys_to_account_keys[ service_key ]: if HG.server_busy.locked(): raise HydrusExceptions.ServerBusyException( 'Sorry, server is busy and cannot fetch account key data right now!' ) account_key = HG.controller.Read( 'account_key_from_access_key', service_key, access_key ) self._service_keys_to_hashed_access_keys_to_account_keys[ service_key ][ hashed_access_key ] = account_key account_key = self._service_keys_to_hashed_access_keys_to_account_keys[ service_key ][ hashed_access_key ] return account_key
def _GetAccountFromAccountKey( self, service_key, account_key ): account_keys_to_accounts = self._service_keys_to_account_keys_to_accounts[ service_key ] if account_key not in account_keys_to_accounts: if HG.server_busy.locked(): raise HydrusExceptions.ServerBusyException( 'Sorry, server is busy and cannot fetch account data right now!' ) account = HG.controller.Read( 'account', service_key, account_key ) account_keys_to_accounts[ account_key ] = account account = account_keys_to_accounts[ account_key ] return account