Ejemplo n.º 1
0
 def finalize(self, result):
     try:
         if self.temp_images is not None:
             import shutil
             shutil.rmtree(self.temp_images)
         if self.temp_exampleimages is not None:
             import shutil
             shutil.rmtree(self.temp_exampleimages)
     except:
         pass
     from cellprofiler.utilities.cpjvm import cp_stop_vm
     try:
         import wx
         app = wx.GetApp()
         if app is not None:
             app.ExitMainLoop()
             app.MainLoop()
         cp_stop_vm(kill=False)
     except:
         logging.root.warn("Failed to shut down AWT", exc_info=1)
     try:
         from ilastik.core.jobMachine import GLOBAL_WM
         GLOBAL_WM.stopWorkers()
     except:
         logging.root.warn("Failed to stop Ilastik")
     try:
         from cellprofiler.utilities.zmqrequest import join_to_the_boundary
         join_to_the_boundary()
     except:
         logging.root.warn("Failed to stop zmq boundary")
Ejemplo n.º 2
0
 def finalize(self, result):
     try:
         if self.temp_images is not None:
             import shutil
             shutil.rmtree(self.temp_images)
         if self.temp_exampleimages is not None:
             import shutil
             shutil.rmtree(self.temp_exampleimages)
     except:
         pass
     from cellprofiler.utilities.cpjvm import cp_stop_vm
     try:
         import wx
         app = wx.GetApp()
         if app is not None:
             app.ExitMainLoop()
             app.MainLoop()
         cp_stop_vm(kill=False)
     except:
         logging.root.warn("Failed to shut down AWT", exc_info=1)
     try:
         from ilastik.core.jobMachine import GLOBAL_WM
         GLOBAL_WM.stopWorkers()
     except:
         logging.root.warn("Failed to stop Ilastik")
     try:
         from cellprofiler.utilities.zmqrequest import join_to_the_boundary
         join_to_the_boundary()
     except:
         logging.root.warn("Failed to stop zmq boundary")
Ejemplo n.º 3
0
def stop_cellprofiler():
    try:
        from cellprofiler.utilities.zmqrequest import join_to_the_boundary
        join_to_the_boundary()
    except:
        logging.root.warn("Failed to stop zmq boundary", exc_info=1)
    try:
        from cellprofiler.utilities.cpjvm import cp_stop_vm
        cp_stop_vm()
    except:
        logging.root.warn("Failed to stop the JVM", exc_info=1)
Ejemplo n.º 4
0
def stop_cellprofiler():
    try:
        from cellprofiler.utilities.zmqrequest import join_to_the_boundary
        join_to_the_boundary()
    except:
        logging.root.warn("Failed to stop zmq boundary", exc_info=1)
    try:
        from cellprofiler.utilities.cpjvm import cp_stop_vm
        cp_stop_vm()
    except:
        logging.root.warn("Failed to stop the JVM", exc_info=1)
Ejemplo n.º 5
0
def stop_cellprofiler():
    try:
        from ilastik.core.jobMachine import GLOBAL_WM
        GLOBAL_WM.stopWorkers()
    except:
        logging.root.warn("Failed to stop Ilastik")
    try:
        from cellprofiler.utilities.zmqrequest import join_to_the_boundary
        join_to_the_boundary()
    except:
        logging.root.warn("Failed to stop zmq boundary", exc_info=1)
    try:
        from cellprofiler.utilities.cpjvm import cp_stop_vm
        cp_stop_vm()
    except:
        logging.root.warn("Failed to stop the JVM", exc_info=1)
Ejemplo n.º 6
0
def stop_cellprofiler():
    try:
        from ilastik.core.jobMachine import GLOBAL_WM
        GLOBAL_WM.stopWorkers()
    except:
        logging.root.warn("Failed to stop Ilastik")
    try:
        from cellprofiler.utilities.zmqrequest import join_to_the_boundary
        join_to_the_boundary()
    except:
        logging.root.warn("Failed to stop zmq boundary", exc_info=1)
    try:
        from cellprofiler.utilities.cpjvm import cp_stop_vm
        cp_stop_vm()
    except:
        logging.root.warn("Failed to stop the JVM", exc_info=1)
Ejemplo n.º 7
0
def main():
    #
    # For OS/X set up the UI elements that users expect from
    # an app.
    #
    if sys.platform == "darwin":
        import os.path

        icon_path = pkg_resources.resource_filename(
            "cellprofiler", os.path.join("data", "icons", "CellProfiler.png"))
        os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker"
        os.environ["APP_ICON_%d" % os.getpid()] = icon_path

    # Start the JVM
    from cellprofiler.utilities.cpjvm import cp_start_vm, cp_stop_vm

    cp_start_vm()

    deadman_start_socket = the_zmq_context.socket(zmq.PAIR)
    deadman_start_socket.bind(DEADMAN_START_ADDR)

    # Start the deadman switch thread.
    start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close")
    deadman_start_socket.recv()
    deadman_start_socket.close()

    from cellprofiler.knime_bridge import KnimeBridgeServer

    with AnalysisWorker(work_announce_address) as worker:
        worker_thread = threading.Thread(target=worker.run,
                                         name="WorkerThread")
        worker_thread.setDaemon(True)
        worker_thread.start()
        with KnimeBridgeServer(the_zmq_context, knime_bridge_address,
                               NOTIFY_ADDR, NOTIFY_STOP):
            worker_thread.join()

    #
    # Shutdown - need to handle some global cleanup here
    #
    try:
        cp_stop_vm()
    except:
        logger.warn("Failed to stop the JVM", exc_info=1)
Ejemplo n.º 8
0
def main():
    #
    # For OS/X set up the UI elements that users expect from
    # an app.
    #
    if sys.platform == "darwin":
        from cellprofiler.icons import get_builtin_images_path
        import os.path
        icon_path = pkg_resources.resource_filename("cellprofiler", os.path.join("data", "icons", "CellProfiler.png"))
        os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker"
        os.environ["APP_ICON_%d" % os.getpid()] = icon_path

    # Start the JVM
    from cellprofiler.utilities.cpjvm import cp_start_vm, cp_stop_vm
    cp_start_vm()

    deadman_start_socket = the_zmq_context.socket(zmq.PAIR)
    deadman_start_socket.bind(DEADMAN_START_ADDR)

    # Start the deadman switch thread.
    start_daemon_thread(target=exit_on_stdin_close,
                        name="exit_on_stdin_close")
    deadman_start_socket.recv()
    deadman_start_socket.close()

    from cellprofiler.knime_bridge import KnimeBridgeServer
    with AnalysisWorker(work_announce_address) as worker:
        worker_thread = threading.Thread(target=worker.run,
                                         name="WorkerThread")
        worker_thread.setDaemon(True)
        worker_thread.start()
        with KnimeBridgeServer(the_zmq_context,
                               knime_bridge_address,
                               NOTIFY_ADDR, NOTIFY_STOP):
            worker_thread.join()

    #
    # Shutdown - need to handle some global cleanup here
    #
    try:
        cp_stop_vm()
    except:
        logger.warn("Failed to stop the JVM", exc_info=1)
Ejemplo n.º 9
0
def main():
    #
    # For Windows build with Ilastik, look for site-packages
    # in order to find Ilastik sources.
    #
    if hasattr(sys, 'frozen') and sys.platform == "win32":
        root = os.path.split(sys.argv[0])[0]
        if len(root) == 0:
            root = os.curdir
        root = os.path.abspath(root)
        site_packages = os.path.join(root, 'site-packages').encode('utf-8')
        if os.path.exists(site_packages) and os.path.isdir(site_packages):
            import site
            site.addsitedir(site_packages)
    #
    # For OS/X set up the UI elements that users expect from
    # an app.
    #
    if sys.platform == "darwin":
        from cellprofiler.icons import get_builtin_images_path

        icon_path = os.path.join(get_builtin_images_path(), "artwork/CellProfilerIcon.png")
        os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker"
        os.environ["APP_ICON_%d" % os.getpid()] = icon_path

    # Start the JVM
    from cellprofiler.utilities.cpjvm import cp_start_vm, cp_stop_vm
    cp_start_vm()

    deadman_start_socket = the_zmq_context.socket(zmq.PAIR)
    deadman_start_socket.bind(DEADMAN_START_ADDR)

    # Start the deadman switch thread.
    start_daemon_thread(target=exit_on_stdin_close,
                        name="exit_on_stdin_close")
    deadman_start_socket.recv()
    deadman_start_socket.close()
    # Limit Ilastik to one job thread.
    try:
        from ilastik.core.jobMachine import GLOBAL_WM
        try:
            GLOBAL_WM.set_thread_count(1)
        except:
            GLOBAL_WM.setThreadCount(1)
    except:
        pass

    from cellprofiler.knime_bridge import KnimeBridgeServer
    with AnalysisWorker(work_announce_address) as worker:
        worker_thread = threading.Thread(target = worker.run,
                                         name="WorkerThread")
        worker_thread.setDaemon(True)
        worker_thread.start()
        with KnimeBridgeServer(the_zmq_context,
                               knime_bridge_address,
                               NOTIFY_ADDR, NOTIFY_STOP):
            enter_run_loop()
            worker_thread.join()

    #
    # Shutdown - need to handle some global cleanup here
    #
    try:
        from ilastik.core.jobMachine import GLOBAL_WM
        GLOBAL_WM.stopWorkers()
    except:
        logger.warn("Failed to stop Ilastik")
    try:
        cp_stop_vm()
    except:
        logger.warn("Failed to stop the JVM", exc_info=1)
 def close(self):
     self.__process_current_set(self.ctx)
     cp_stop_vm()
Ejemplo n.º 11
0
        raise
    
    finally:
        if __name__ == "__main__":
            try:
                from ilastik.core.jobMachine import GLOBAL_WM
                GLOBAL_WM.stopWorkers()
            except:
                logging.root.warn("Failed to stop Ilastik")
            try:
                from cellprofiler.utilities.zmqrequest import join_to_the_boundary
                join_to_the_boundary()
            except:
                logging.root.warn("Failed to stop zmq boundary", exc_info=1)
            try:
                cp_stop_vm()
            except:
                logging.root.warn("Failed to stop the JVM", exc_info=1)
            os._exit(0)

def parse_args(args):
    '''Parse the CellProfiler command-line arguments'''
    import optparse
    usage = """usage: %prog [options] [<output-file>])
         where <output-file> is the optional filename for the output file of 
               measurements when running headless. 
         The flags -p, -r and -c are required for a headless run."""
    
    parser = optparse.OptionParser(usage=usage)
    parser.add_option("-p", "--pipeline", "--project",
                      dest="pipeline_filename",
Ejemplo n.º 12
0
def main():
    #
    # For Windows build with Ilastik, look for site-packages
    # in order to find Ilastik sources.
    #
    if hasattr(sys, 'frozen') and sys.platform == "win32":
        root = os.path.split(sys.argv[0])[0]
        if len(root) == 0:
            root = os.curdir
        root = os.path.abspath(root)
        site_packages = os.path.join(root, 'site-packages').encode('utf-8')
        if os.path.exists(site_packages) and os.path.isdir(site_packages):
            import site
            site.addsitedir(site_packages)
    #
    # For OS/X set up the UI elements that users expect from
    # an app.
    #
    if sys.platform == "darwin":
        from cellprofiler.icons import get_builtin_images_path

        icon_path = os.path.join(get_builtin_images_path(),
                                 "artwork/CellProfilerIcon.png")
        os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker"
        os.environ["APP_ICON_%d" % os.getpid()] = icon_path

    # Start the JVM
    from cellprofiler.utilities.cpjvm import cp_start_vm, cp_stop_vm
    cp_start_vm()

    deadman_start_socket = the_zmq_context.socket(zmq.PAIR)
    deadman_start_socket.bind(DEADMAN_START_ADDR)

    # Start the deadman switch thread.
    start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close")
    deadman_start_socket.recv()
    deadman_start_socket.close()
    # Limit Ilastik to one job thread.
    try:
        from ilastik.core.jobMachine import GLOBAL_WM
        try:
            GLOBAL_WM.set_thread_count(1)
        except:
            GLOBAL_WM.setThreadCount(1)
    except:
        pass

    from cellprofiler.knime_bridge import KnimeBridgeServer
    with AnalysisWorker(work_announce_address) as worker:
        worker_thread = threading.Thread(target=worker.run,
                                         name="WorkerThread")
        worker_thread.setDaemon(True)
        worker_thread.start()
        with KnimeBridgeServer(the_zmq_context, knime_bridge_address,
                               NOTIFY_ADDR, NOTIFY_STOP):
            enter_run_loop()
            worker_thread.join()

    #
    # Shutdown - need to handle some global cleanup here
    #
    try:
        from ilastik.core.jobMachine import GLOBAL_WM
        GLOBAL_WM.stopWorkers()
    except:
        logger.warn("Failed to stop Ilastik")
    try:
        cp_stop_vm()
    except:
        logger.warn("Failed to stop the JVM", exc_info=1)
Ejemplo n.º 13
0
 def close(self):
     self.__process_current_set(self.ctx)
     cp_stop_vm()
Ejemplo n.º 14
0
        raise

    finally:
        if __name__ == "__main__":
            try:
                from ilastik.core.jobMachine import GLOBAL_WM
                GLOBAL_WM.stopWorkers()
            except:
                logging.root.warn("Failed to stop Ilastik")
            try:
                from cellprofiler.utilities.zmqrequest import join_to_the_boundary
                join_to_the_boundary()
            except:
                logging.root.warn("Failed to stop zmq boundary", exc_info=1)
            try:
                cp_stop_vm()
            except:
                logging.root.warn("Failed to stop the JVM", exc_info=1)
            os._exit(0)


def parse_args(args):
    '''Parse the CellProfiler command-line arguments'''
    import optparse
    usage = """usage: %prog [options] [<output-file>])
         where <output-file> is the optional filename for the output file of 
               measurements when running headless. 
         The flags -p, -r and -c are required for a headless run."""

    parser = optparse.OptionParser(usage=usage)
    parser.add_option("-p",