Example #1
0
def check_app(name, exe_name=None, window_name=None, service_name=None):
    """Check if a program or service is running

    :param name: common name for the process.
    :param exe_name: executable name of the process.
    :param window_name: title of the process.
    :param service_name: name of the service.

    """
    try:
        if exe_name is not None:
            handler = StartStop()
            handler.exeName = exe_name
            res = handler.probeProcess()
        elif window_name is not None:
            handler = CMDStartStop()
            handler.windowName = window_name
            res = handler.probeProcess()
        elif service_name is not None:
            handler = StartStop()
            handler.serviceName = service_name
            res = handler.probeService()
        else:
            raise Exception("exe_name, window_name, or service_name should be "
                            "given.")
    except:
        res = EXCEPTION
    pStdout(name, res)