Skip to content

MORPHEEProcessControl

Below a sample that starts MORPHEE, reply to any MORPHEE report window, wait for MORPHEE to stop.

from restmapi.services import MAPIServices
import time

global started
global morphee_process_control
started = 0

def morphee_started(instance):
    global started  
    print(f"MORPHEE instance {instance} started")
    started = 1 
def morphee_stopped(instance):
    global started  
    print(f"MORPHEE instance {instance} stopped")
    started = 0 
def morphee_report_updated(instance):
    global morphee_process_control  
    if morphee_process_control.is_report_pending(instance):
        print(f"MORPHEE instance {instance} report:")
        print(morphee_process_control.get_report_messages(instance))
        morphee_process_control.close_report(instance)
    else:
        print("report closed")  

print(MAPIServices.instance.mapi_base_url)
print(MAPIServices.instance.get_version())
with MAPIServices.instance.get_service("MorpheeProcessControl") as morphee_process_control:
    morphee_process_control.init_signalr()
    morphee_process_control.register_started_callback(morphee_started)
    morphee_process_control.register_stopped_callback(morphee_stopped)
    morphee_process_control.register_report_updated_callback(morphee_report_updated)
    print(morphee_process_control.start())
    while started == 0:
        time.sleep(1)       
    while started == 1:
        time.sleep(1)