Beispiel #1
0
    def delete_trace(self, uuid, delete_trace, remove_cache=False):
        '''
        Delete a trace on the server
        :param uuid: Trace UUID to delete
        :param delete_trace: Also delete the trace from disk
        :param remove_cache: Remove all cache for this trace
        :return: :class:`TspClientResponse <Trace>` object
        :rtype: TspClientResponse
        '''
        api_url = '{0}traces/{1}'.format(self.base_url, uuid)
        parameters = {}
        if delete_trace:  # pragma: no cover
            parameters['deleteTrace'] = "true"

        if remove_cache:
            parameters['removeCache'] = "true"

        response = requests.delete(api_url, json=parameters, headers=headers)
        if response.status_code == 200:
            return TspClientResponse(
                Trace(json.loads(response.content.decode('utf-8'))),
                response.status_code, response.text)
        else:  # pragma: no cover
            print("delete trace failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
Beispiel #2
0
    def fetch_xy_tree(self, exp_uuid, output_id, parameters=None):
        '''
        Fetch XY tree, Model extends Entry
        :param exp_uuid: Experiment UUID
        :param output_id: Output ID
        :param parameters: Query object
        :returns: :class:  `TspClientResponse <GenericResponse>` object XY entries response
        :rtype: TspClientResponse
        '''
        api_url = '{0}experiments/{1}/outputs/XY/{2}/tree'.format(
            self.base_url, exp_uuid, output_id)

        params = parameters
        if parameters is None:
            params = {}

        response = requests.post(api_url, json=params, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(
                GenericResponse(json.loads(response.content.decode('utf-8')),
                                ModelType.XY_TREE), response.status_code,
                response.text)
        else:  # pragma: no cover
            print("failed to get tree: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
 def fetch_trace(self, uuid):
     api_url = '{0}traces/{1}'.format(self.base_url, uuid)
     response = requests.get(api_url, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
     else:
         print ("get trace failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
    def experiment_outputs(self, exp_uuid):
        api_url = '{0}experiments/{1}/outputs/'.format(self.base_url, exp_uuid)

        response = requests.get(api_url, headers=headers)
    
        if response.status_code == 200:
            return TspClientResponse(OutputDescriptorSet(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
        else:
            print ("get output descriptors failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
Beispiel #5
0
 def delete_experiment(self, uuid):
     api_url = '{0}experiments/{1}'.format(self.base_url, uuid)
     response = requests.delete(api_url, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(
             Trace(json.loads(response.content.decode('utf-8'))),
             response.status_code, response.text)
     else:
         print("delete experiment failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
Beispiel #6
0
 def fetch_experiments(self):
     api_url = '{0}experiments'.format(self.base_url)
     response = requests.get(api_url, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(
             ExperimentSet(json.loads(response.content.decode('utf-8'))),
             response.status_code, response.text)
     else:
         print("get experiments failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
Beispiel #7
0
    def delete_extensions(self, name):
        api_url = '{0}xml/{1}'.format(self.base_url, name)

        response = requests.delete(api_url, headers=headers_form)

        if response.status_code == 200:
            return TspClientResponse("Deleted", response.status_code,
                                     response.text)
        else:
            print("post extension failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
Beispiel #8
0
    def post_extensions(self, mypath):
        api_url = '{0}xml'.format(self.base_url)

        payload = dict(path=mypath)
        response = requests.post(api_url, data=payload, headers=headers_form)

        if response.status_code == 200:
            return TspClientResponse("Loaded", response.status_code,
                                     response.text)
        else:
            print("post extension failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
Beispiel #9
0
 def fetch_traces(self):
     '''
     Fetch all available traces on the server
     :return: :class:`TspClientResponse <TraceSet>` object
     :rtype: TspClientResponse
     '''
     api_url = '{0}traces'.format(self.base_url)
     response = requests.get(api_url, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(TraceSet(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
     else:  # pragma: no cover
         print("get traces failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
Beispiel #10
0
    def fetch_extensions(self):
        '''
        Fetch Extensions (loaded files)
        '''
        api_url = '{0}xml'.format(self.base_url)

        response = requests.get(api_url, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(ExtensionSet(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
        else:  # pragma: no cover
            print("failed to get extensions: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
Beispiel #11
0
 def fetch_trace(self, uuid):
     '''
     Fetch a specific trace information
     :param uuid: Trace UUID to fetch
     :return: :class:`TspClientResponse <Trace>` object
     :rtype: TspClientResponse
     '''
     api_url = '{0}traces/{1}'.format(self.base_url, uuid)
     response = requests.get(api_url, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
     else:
         print("get trace failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
Beispiel #12
0
 def delete_experiment(self, uuid):
     '''
     Delete a specific experiment
     :param uuid: Trace UUID to fetch
     :return: :class:`TspClientResponse <Trace>` object
     :rtype: TspClientResponse
     '''
     api_url = '{0}experiments/{1}'.format(self.base_url, uuid)
     response = requests.delete(api_url, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(Experiment(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
     else:  # pragma: no cover
         print("delete experiment failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
 def delete_trace(self, uuid, delete_trace, remove_cache=False):
     api_url = '{0}traces/{1}'.format(self.base_url, uuid)
     parameters = {};
     if delete_trace: 
         parameters.append('deleteTrace', "true")
     
     if remove_cache: {
         parameters.append('removeCache', "true")
     }
     response = requests.delete(api_url, json=parameters, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
     else:
         print ("delete trace failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
Beispiel #14
0
    def open_trace(self, name, path):
        api_url = '{0}traces'.format(self.base_url)

        my_parameters = {'name': name, 'uri': path}
        parameters = {'parameters': my_parameters}

        response = requests.post(api_url, json=parameters, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(
                Trace(json.loads(response.content.decode('utf-8'))),
                response.status_code, response.text)
        else:
            print("post trace failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
Beispiel #15
0
    def fetch_experiment_outputs(self, exp_uuid):
        '''
        List all the outputs associated to this experiment
        :param exp_uuid: Experiment UUID
        :return: :class:  `TspClientResponse <OutputDescriptorSet>` object
        :rtype: TspClientResponse
        '''
        api_url = '{0}experiments/{1}/outputs'.format(self.base_url, exp_uuid)

        response = requests.get(api_url, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(OutputDescriptorSet(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
        else:  # pragma: no cover
            print("get output descriptors failed: {0}".format(
                response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
 def fetch_timegraph_tree(self, exp_uuid, output_id, parameters = None):
     api_url = '{0}experiments/{1}/outputs/timeGraph/{2}/tree'.format(self.base_url, exp_uuid, output_id)
     
     if (parameters == None): 
         requested_times= [0, 1]
         my_parameters = {'requested_times': requested_times}
         params = {'parameters': my_parameters}
     else:
         params = parameters    
 
     response = requests.post(api_url, json=params, headers=headers)
 
     if response.status_code == 200:
         return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')), ModelType.TREE), response.status_code, response.text)
     else:    
         print ("failed to get tree: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
Beispiel #17
0
    def open_experiment(self, name, traces):
        '''
        Create an experiment on the server
        :param parameters: Query object
        :rtype: The created experiment
        '''
        api_url = '{0}experiments'.format(self.base_url)

        my_parameters = {'name': name, 'traces': traces}
        parameters = {'parameters': my_parameters}

        response = requests.post(api_url, json=parameters, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(Experiment(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
        else:  # pragma: no cover
            print("post experiment failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
Beispiel #18
0
    def open_trace(self, name, path):
        '''
        Open a trace on the server
        parameters: Query object
        :return: :class:`TspClientResponse <Trace>` object
        :rtype: TspClientResponse
        '''
        api_url = '{0}traces'.format(self.base_url)

        my_parameters = {'name': name, 'uri': path}
        parameters = {'parameters': my_parameters}

        response = requests.post(api_url, json=parameters, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
        else:  # pragma: no cover
            print("post trace failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
Beispiel #19
0
    def fetch_experiment_output(self, exp_uuid, output_id):
        '''
        Fetch given output descriptor
        :param exp_uuid: Experiment UUID
        :param output_id: Output ID
        :param parameters: Query object
        :returns: :class:  `TspClientResponse <OutputDescriptor>` object OutputDescriptor
        :rtype: TspClientResponse
        '''
        api_url = '{0}experiments/{1}/outputs/{2}'.format(
            self.base_url, exp_uuid, output_id)

        response = requests.get(api_url, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(OutputDescriptor(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
        else:  # pragma: no cover
            print("failed to get tree: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
Beispiel #20
0
    def fetch_xy(self, exp_uuid, output_id, parameters):
        '''
        Fetch XY xy, XYModel
        :param exp_uuid: Experiment UUID
        :param output_id: Output ID
        :param parameters: Query object (mandatory here; no defaults possible)
        :returns: :class:  `TspClientResponse <GenericResponse>` object XY series response
        :rtype: TspClientResponse
        '''
        api_url = '{0}experiments/{1}/outputs/XY/{2}/xy'.format(
            self.base_url, exp_uuid, output_id)

        response = requests.post(api_url, json=parameters, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')), ModelType.XY), response.status_code, response.text)
        else:  # pragma: no cover
            print("failed to get xy: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
 def open_trace(self, name, path):
     api_url = '{0}traces'.format(self.base_url)
     
     my_parameters = {'name': name, 'uri': path}
     parameters = {'parameters': my_parameters}
     
     response = requests.post(api_url, json=parameters, headers=headers)
     
     if response.status_code == 200:
         return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
     elif response.status_code == 409:
         fetch_response = self.fetch_traces()
         if fetch_response.status_code == 200:
             #TODO don't just blindly use the first one
             return TspClientResponse(fetch_response.model.traces[0], response.status_code, response.text)
         else:
             return TspClientResponse(None, fetch_response.status_code, fetch_response.status_text)
     else:
         print ("post trace failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)