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(), "CellProfilerIcon.png") os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker" os.environ["APP_ICON_%d" % os.getpid()] = icon_path J.javabridge.mac_run_loop_init() # Importing bioformats starts the JVM import bioformats # Start the deadman switch thread. start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close") with stdin_monitor_lock: while not stdin_monitor_started: stdin_monitor_cv.wait() with AnalysisWorker(work_announce_address) as worker: worker_thread = threading.Thread(target = worker.run, name="WorkerThread") worker_thread.setDaemon(True) worker_thread.start() print "Entering run loop" enter_run_loop() print "Exiting 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: J.kill_vm() except: logger.warn("Failed to stop the Java VM")
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(), "CellProfilerIcon.png") os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker" os.environ["APP_ICON_%d" % os.getpid()] = icon_path J.javabridge.mac_run_loop_init() # Importing bioformats starts the JVM import bioformats # Start the deadman switch thread. start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close") with stdin_monitor_lock: while not stdin_monitor_started: stdin_monitor_cv.wait() with AnalysisWorker(work_announce_address) as worker: worker_thread = threading.Thread(target=worker.run, name="WorkerThread") worker_thread.setDaemon(True) worker_thread.start() print "Entering run loop" enter_run_loop() print "Exiting 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: J.kill_vm() except: logger.warn("Failed to stop the Java VM")
def get_cp_icon(size=None): """The CellProfiler icon as a wx.Icon""" import wx if sys.platform.startswith('win'): path = os.path.join(get_builtin_images_path(), "CellProfilerIcon.ico") icon = wx.EmptyIcon() icon.LoadFile(path, wx.BITMAP_TYPE_ICO) return icon icon = wx.EmptyIcon() icon.CopyFromBitmap(get_cp_bitmap(size)) return icon
def OnOpeningURL(self, type, url): if type == wx.html.HTML_URL_IMAGE: if url.startswith(MEMORY_SCHEME): path = get_builtin_images_path() full_path = os.path.join(path, url[len(MEMORY_SCHEME):]) if sys.platform.startswith("win"): my_url = full_path else: my_url = "file:" + urllib.pathname2url(full_path) return my_url return wx.html.HTML_OPEN
def main(): # XXX - move all this to a class # # 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(), "CellProfilerIcon.png") os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker" os.environ["APP_ICON_%d" % os.getpid()] = icon_path J.javabridge.mac_run_loop_init() # Importing bioformats starts the JVM import bioformats # Start the deadman switch thread. start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close") with stdin_monitor_lock: while not stdin_monitor_started: stdin_monitor_cv.wait() with AnalysisWorker(work_announce_address) as worker: worker_thread = threading.Thread(target = worker.run, name="WorkerThread") worker_thread.setDaemon(True) worker_thread.start() print "Entering run loop" enter_run_loop() print "Exiting 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: J.kill_vm() except: logger.warn("Failed to stop the Java VM")
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 icon_path = os.path.join(get_builtin_images_path(), "data/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() 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)
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 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() 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)
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(), "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_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): 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: from imagej.imagej2 import allow_quit allow_quit() except: logger.warn("Failed to signal ImageJ to stop") try: J.kill_vm() except: logger.warn("Failed to stop the Java VM")
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 main(): # XXX - move all this to a class parser = optparse.OptionParser() parser.add_option("--work-announce", dest="work_announce_address", help="ZMQ port where work announcements are published", default=None) parser.add_option("--log-level", dest="log_level", help="Logging level for logger: DEBUG, INFO, WARNING, ERROR", default=logging.INFO) options, args = parser.parse_args() logging.root.setLevel(options.log_level) if not options.work_announce_address: parser.print_help() sys.exit(1) # # 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(), "CellProfilerIcon.png") os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker" os.environ["APP_ICON_%d" % os.getpid()] = icon_path J.javabridge.mac_run_loop_init() # Importing bioformats starts the JVM import bioformats # Start the deadman switch thread. start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close") with stdin_monitor_lock: while not stdin_monitor_started: stdin_monitor_cv.wait() with AnalysisWorker(options.work_announce_address) as worker: worker_thread = threading.Thread(target = worker.run, name="WorkerThread") worker_thread.setDaemon(True) worker_thread.start() print "Entering run loop" enter_run_loop() print "Exiting 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: J.kill_vm() except: logger.warn("Failed to stop the Java VM")
def main(): # XXX - move all this to a class parser = optparse.OptionParser() parser.add_option("--work-announce", dest="work_announce_address", help="ZMQ port where work announcements are published", default=None) parser.add_option( "--log-level", dest="log_level", help="Logging level for logger: DEBUG, INFO, WARNING, ERROR", default=logging.INFO) options, args = parser.parse_args() logging.root.setLevel(options.log_level) if not options.work_announce_address: parser.print_help() sys.exit(1) # # 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(), "CellProfilerIcon.png") os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker" os.environ["APP_ICON_%d" % os.getpid()] = icon_path J.javabridge.mac_run_loop_init() # Importing bioformats starts the JVM import bioformats # Start the deadman switch thread. start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close") with stdin_monitor_lock: while not stdin_monitor_started: stdin_monitor_cv.wait() with AnalysisWorker(options.work_announce_address) as worker: worker_thread = threading.Thread(target=worker.run, name="WorkerThread") worker_thread.setDaemon(True) worker_thread.start() print "Entering run loop" enter_run_loop() print "Exiting 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: J.kill_vm() except: logger.warn("Failed to stop the Java VM")