Ejemplo n.º 1
0
def protocol_response(method, protocol_path=None, response_path=None, **kwargs):
    """
    Helper function for getting protocol response and dumping json to response path
    Caveat Emptor: Does not do any additional checks on the response object, just dumps to json if possible
    """
    from transcriptic import api
    if not api:
        from transcriptic.config import Connection
        api = Connection.from_file("~/.transcriptic")
    protocol = json.loads(open(protocol_path).read())

    response = requests.post(api.get_route(method), headers=api.headers, data=json.dumps({'protocol': protocol}))
    with open(response_path, 'w') as out_file:
        json.dump(response.json(), out_file, indent=2)
Ejemplo n.º 2
0
def protocol_response(method,
                      protocol_path=None,
                      response_path=None,
                      **kwargs):
    """
    Helper function for getting protocol response and dumping json to response path
    Caveat Emptor: Does not do any additional checks on the response object, just dumps to json if possible
    """
    from transcriptic import api
    if not api:
        from transcriptic.config import Connection
        api = Connection.from_file("~/.transcriptic")
    protocol = json.loads(open(protocol_path).read())

    response = requests.post(api.get_route(method),
                             headers=api.session.headers,
                             data=json.dumps({'protocol': protocol}))
    with open(response_path, 'w') as out_file:
        json.dump(response.json(), out_file, indent=2)
Ejemplo n.º 3
0
    def display(self):
        """
        Displays the original full-sized image. Helpful when used in an IPython
        kernel

        Returns
        -------
        HTML
            Returns a HTML iframe of the full-size image which is rendered nicely in IPython (if IPython is present)
        """
        try:
            from IPython.display import HTML
            return (HTML("""<iframe src="%s")" frameborder="0" \
                allowtransparency="true" style="height:500px;" seamless> \
                </iframe>""" % api.get_route('view_raw_image', data_id=self.id)))

        except:
            # If IPython module is not present or unable to show, display using
            # default PIL image show
            self.image.show()
Ejemplo n.º 4
0
    def display(self):
        """
        Displays the original full-sized image. Helpful when used in an IPython
        kernel

        Returns
        -------
        HTML
            Returns a HTML iframe of the full-size image which is rendered nicely in IPython (if IPython is present)
        """
        try:
            from IPython.display import HTML
            return (HTML("""<iframe src="%s")" frameborder="0" \
                allowtransparency="true" style="height:500px;" seamless> \
                </iframe>""" %
                         api.get_route('view_raw_image', data_id=self.id)))

        except:
            # If IPython module is not present or unable to show, display using
            # default PIL image show
            self.image.show()