示例#1
0
    def _threadDoPOSTJob(self, request):

        services = request.parsed_request_args['services']

        unique_ports = {service.GetPort() for service in services}

        if len(unique_ports) < len(services):

            raise HydrusExceptions.BadRequestException(
                'It looks like some of those services share ports! Please give them unique ports!'
            )

        with HG.dirty_object_lock:

            HG.server_controller.SetServices(services)

            service_keys_to_access_keys = HG.server_controller.WriteSynchronous(
                'services', request.hydrus_account, services)

        body = HydrusNetwork.DumpHydrusArgsToNetworkBytes(
            {'service_keys_to_access_keys': service_keys_to_access_keys})

        response_context = HydrusServerResources.ResponseContext(200,
                                                                 body=body)

        return response_context
示例#2
0
    def _threadDoGETJob(self, request):

        num = request.parsed_request_args['num']
        account_type_key = request.parsed_request_args['account_type_key']

        if 'expires' in request.parsed_request_args:

            expires = request.parsed_request_args['expires']

        else:

            expires = None

        registration_keys = HG.server_controller.Read('registration_keys',
                                                      self._service_key,
                                                      request.hydrus_account,
                                                      num, account_type_key,
                                                      expires)

        body = HydrusNetwork.DumpHydrusArgsToNetworkBytes(
            {'registration_keys': registration_keys})

        response_context = HydrusServerResources.ResponseContext(200,
                                                                 body=body)

        return response_context
示例#3
0
    def _threadDoGETJob(self, request):

        subject_identifier = request.parsed_request_args['subject_identifier']

        if subject_identifier.HasAccountKey():

            subject_account_key = subject_identifier.GetData()

        else:

            raise HydrusExceptions.MissingCredentialsException(
                'I was expecting an account key, but did not get one!')

        subject_account = HG.server_controller.Read('account',
                                                    self._service_key,
                                                    subject_account_key)

        account_info = HG.server_controller.Read('account_info',
                                                 self._service_key,
                                                 request.hydrus_account,
                                                 subject_account)

        body = HydrusNetwork.DumpHydrusArgsToNetworkBytes(
            {'account_info': account_info})

        response_context = HydrusServerResources.ResponseContext(200,
                                                                 body=body)

        return response_context
示例#4
0
 def _threadDoGETJob( self, request ):
     
     services = HG.server_controller.Read( 'services_from_account', request.hydrus_account )
     
     body = HydrusNetwork.DumpHydrusArgsToNetworkBytes( { 'services' : services } )
     
     response_context = HydrusServerResources.ResponseContext( 200, body = body )
     
     return response_context
示例#5
0
 def _threadDoGETJob( self, request ):
     
     petition_count_info = HG.server_controller.Read( 'num_petitions', self._service_key, request.hydrus_account )
     
     body = HydrusNetwork.DumpHydrusArgsToNetworkBytes( { 'num_petitions' : petition_count_info } )
     
     response_context = HydrusServerResources.ResponseContext( 200, body = body )
     
     return response_context
示例#6
0
 def _threadDoGETJob( self, request ):
     
     account = request.hydrus_account
     
     body = HydrusNetwork.DumpHydrusArgsToNetworkBytes( { 'account' : account } )
     
     response_context = HydrusServerResources.ResponseContext( 200, body = body )
     
     return response_context
示例#7
0
 def _threadDoGETJob( self, request ):
     
     updates = HG.server_controller.Read( 'immediate_update', self._service_key, request.hydrus_account )
     
     updates = HydrusSerialisable.SerialisableList( updates )
     
     body = HydrusNetwork.DumpHydrusArgsToNetworkBytes( { 'updates' : updates } )
     
     response_context = HydrusServerResources.ResponseContext( 200, body = body )
     
     return response_context
示例#8
0
 def _threadDoGETJob( self, request ):
     
     hash = request.parsed_request_args[ 'hash' ]
     
     ( ip, timestamp ) = HG.server_controller.Read( 'ip', self._service_key, request.hydrus_account, hash )
     
     body = HydrusNetwork.DumpHydrusArgsToNetworkBytes( { 'ip' : ip, 'timestamp' : timestamp } )
     
     response_context = HydrusServerResources.ResponseContext( 200, body = body )
     
     return response_context
示例#9
0
 def _threadDoGETJob( self, request ):
     
     access_key = self._parseHydrusNetworkAccessKey( request )
     
     verified = HG.server_controller.Read( 'verify_access_key', self._service_key, access_key )
     
     body = HydrusNetwork.DumpHydrusArgsToNetworkBytes( { 'verified' : verified } )
     
     response_context = HydrusServerResources.ResponseContext( 200, body = body )
     
     return response_context
示例#10
0
 def _threadDoGETJob( self, request ):
     
     registration_key = request.parsed_request_args[ 'registration_key' ]
     
     access_key = HG.server_controller.Read( 'access_key', self._service_key, registration_key )
     
     body = HydrusNetwork.DumpHydrusArgsToNetworkBytes( { 'access_key' : access_key } )
     
     response_context = HydrusServerResources.ResponseContext( 200, body = body )
     
     return response_context
示例#11
0
 def _threadDoGETJob( self, request ):
     
     content_type = request.parsed_request_args[ 'content_type' ]
     status = request.parsed_request_args[ 'status' ]
     
     petition = HG.server_controller.Read( 'petition', self._service_key, request.hydrus_account, content_type, status )
     
     body = HydrusNetwork.DumpHydrusArgsToNetworkBytes( { 'petition' : petition } )
     
     response_context = HydrusServerResources.ResponseContext( 200, body = body )
     
     return response_context
示例#12
0
 def _threadDoGETJob( self, request ):
     
     # no permissions check as any functional account can get metadata slices
     
     since = request.parsed_request_args[ 'since' ]
     
     metadata_slice = self._service.GetMetadataSlice( since )
     
     body = HydrusNetwork.DumpHydrusArgsToNetworkBytes( { 'metadata_slice' : metadata_slice } )
     
     response_context = HydrusServerResources.ResponseContext( 200, body = body )
     
     return response_context