def execute_script(script): """ Run a python script and exit. Provides a way for people with pre-installed binaries to use the glue library """ from glue.utils.qt.decorators import die_on_error with die_on_error("Error running script"): with open(script) as fin: exec(fin.read()) sys.exit(0)
def execute_script(script): """ Run a python script and exit. Provides a way for people with pre-installed binaries to use the glue library """ from glue.utils.qt.decorators import die_on_error with die_on_error("Error running script"): with open(script) as fin: exec(fin.read()) sys.exit(0)
def start_glue(gluefile=None, config=None, datafiles=None, maximized=True, startup_actions=None, auto_merge=False): """Run a glue session and exit Parameters ---------- gluefile : str An optional ``.glu`` file to restore. config : str An optional configuration file to use. datafiles : str An optional list of data files to load. maximized : bool Maximize screen on startup. Otherwise, use default size. auto_merge : bool, optional Whether to automatically merge data passed in `datafiles` (default is `False`) """ import glue # Some Qt modules are picky in terms of being imported before the # application is set up, so we import them here. We do it here rather # than in get_qapp since in the past, including this code in get_qapp # caused severe issues (e.g. segmentation faults) in plugin packages # during testing. try: from qtpy import QtWebEngineWidgets # noqa except ImportError: # Not all PyQt installations have this module pass from glue.utils.qt.decorators import die_on_error from glue.utils.qt import get_qapp app = get_qapp() splash = get_splash() splash.show() # Start off by loading plugins. We need to do this before restoring # the session or loading the configuration since these may use existing # plugins. load_plugins(splash=splash, require_qt_plugins=True) from glue.app.qt import GlueApplication datafiles = datafiles or [] hub = None from qtpy.QtCore import QTimer timer = QTimer() timer.setInterval(1000) timer.setSingleShot(True) timer.timeout.connect(splash.close) timer.start() if gluefile is not None: with die_on_error("Error restoring Glue session"): app = GlueApplication.restore_session(gluefile, show=False) return app.start(maximized=maximized) if config is not None: glue.env = glue.config.load_configuration(search_path=[config]) data_collection = glue.core.DataCollection() hub = data_collection.hub splash.set_progress(100) session = glue.core.Session(data_collection=data_collection, hub=hub) ga = GlueApplication(session=session) if datafiles: with die_on_error("Error reading data file"): datasets = load_data_files(datafiles) ga.add_datasets(datasets, auto_merge=auto_merge) if startup_actions is not None: for name in startup_actions: ga.run_startup_action(name) return ga.start(maximized=maximized)
def start_glue(gluefile=None, config=None, datafiles=None, maximized=True, startup_actions=None, auto_merge=False): """Run a glue session and exit Parameters ---------- gluefile : str An optional ``.glu`` file to restore. config : str An optional configuration file to use. datafiles : str An optional list of data files to load. maximized : bool Maximize screen on startup. Otherwise, use default size. auto_merge : bool, optional Whether to automatically merge data passed in `datafiles` (default is `False`) """ import glue # Some Qt modules are picky in terms of being imported before the # application is set up, so we import them here. We do it here rather # than in get_qapp since in the past, including this code in get_qapp # caused severe issues (e.g. segmentation faults) in plugin packages # during testing. try: from qtpy import QtWebEngineWidgets # noqa except ImportError: # Not all PyQt installations have this module pass from glue.utils.qt.decorators import die_on_error from glue.utils.qt import get_qapp app = get_qapp() splash = get_splash() splash.show() # Start off by loading plugins. We need to do this before restoring # the session or loading the configuration since these may use existing # plugins. load_plugins(splash=splash) from glue.app.qt import GlueApplication datafiles = datafiles or [] hub = None from qtpy.QtCore import QTimer timer = QTimer() timer.setInterval(1000) timer.setSingleShot(True) timer.timeout.connect(splash.close) timer.start() if gluefile is not None: with die_on_error("Error restoring Glue session"): app = GlueApplication.restore_session(gluefile, show=False) return app.start(maximized=maximized) if config is not None: glue.env = glue.config.load_configuration(search_path=[config]) data_collection = glue.core.DataCollection() hub = data_collection.hub splash.set_progress(100) session = glue.core.Session(data_collection=data_collection, hub=hub) ga = GlueApplication(session=session) if datafiles: with die_on_error("Error reading data file"): datasets = load_data_files(datafiles) ga.add_datasets(data_collection, datasets, auto_merge=auto_merge) if startup_actions is not None: for name in startup_actions: ga.run_startup_action(name) return ga.start(maximized=maximized)