diff --git a/model_server/clients/imagej/adapter.py b/model_server/clients/imagej/adapter.py index 4f977c2c7fd48a837615b573aae847be09f9374c..283f621dff8a84ec9a9929ed4e3039cc2e70d06f 100644 --- a/model_server/clients/imagej/adapter.py +++ b/model_server/clients/imagej/adapter.py @@ -6,6 +6,7 @@ import httplib import json import urllib +from ij import IJ from ij import ImagePlus HOST = '127.0.0.1' @@ -36,6 +37,22 @@ def hit_endpoint(method, endpoint, params=None): content = {'str': str(resp_str)} return {'status': resp.status, 'content': content} + +def verify_server(popup=True): + resp = hit_endpoint('GET', '/') + if resp['status'] == 404: + msg = f'Could not find server found at {uri}' + IJ.log(msg) + if popup: + IJ.error(msg) + elif resp['status'] != 200: + msg = f'Unknown error verifying server at {uri}' + if popup: + IJ.error(msg) + else: + IJ.log(f'Verified server is online at {uri}') + return True + def run_request_sequence(imp, func, params): """ Execute a sequence of client requests in the ImageJ scripting environment