Esempio n. 1
0
    def __init__(self, qt_is_safe=False):

        self.qt_is_safe = qt_is_safe
        self._blacklist = []
        self._load_queue = LifoQueue()
        self._instantiate_queue = LifoQueue()
        self._entrypoints = {}
        self._load_cache = {}
        self._observers = []
        self.state = State.READY
        self.type_mapping = {}
        self.plugin_types = {}

        # Remember all modules loaded before any plugins are loaded; don't bother unloading these
        self._preloaded_modules = set(sys.modules.keys())

        # Observe changes to venvs
        if venvsobservers is not None:
            venvsobservers.append(self)

        self.initialize_types()

        # Check if cammart should be ignored
        try:
            args = parse_args(exit_on_fail=False)
            include_cammart = not args.nocammart
            self._blacklist = args.blacklist
        except RuntimeError:
            include_cammart = False

        # ...if so, blacklist it
        if not include_cammart:
            self._blacklist.extend(["cammart", "venvs"])
Esempio n. 2
0
    def __init__(self, qt_is_safe=False):

        self.qt_is_safe = qt_is_safe
        self._blacklist = []
        self._tasks = []
        self._load_queue = LifoQueue()
        self._instantiate_queue = LifoQueue()
        self._observers = []
        self.type_mapping = {}
        self.plugin_types = {}
        self.instantiating = False

        # A QRunnable-based background Worker
        self.plugin_loader = threads.QThreadFutureIterator(self._load_plugins)

        # Remember all modules loaded before any plugins are loaded; don't bother unloading these
        self._preloaded_modules = set(sys.modules.keys())

        # Observe changes to venvs
        if venvsobservers is not None:
            venvsobservers.append(self)

        self.initialize_types()

        # Check if cammart should be ignored
        try:
            args = parse_args(exit_on_fail=False)
            include_cammart = not args.nocammart
            self._blacklist = args.blacklist
        except RuntimeError:
            include_cammart = False

        # ...if so, blacklist it
        if not include_cammart:
            self._blacklist.extend(["cammart", "venvs"])
Esempio n. 3
0
    def __init__(self):

        self._blacklist = []
        self._load_queue = LifoQueue()
        self._instantiate_queue = LifoQueue()
        self._entrypoints = {}
        self._load_cache = {}
        self._observers = []
        self.state = State.READY
        self.type_mapping = {}
        self.plugin_types = {}

        # Remember all modules loaded before any plugins are loaded; don't bother unloading these
        self._preloaded_modules = set(sys.modules.keys())

        # Observe changes to venvs
        if venvsobservers is not None:
            venvsobservers.append(self)

        # Load plugin types
        self.plugin_types = {
            name: ep.load()
            for name, ep in entrypoints.get_group_named(
                'xicam.plugins.PluginType').items()
        }

        # Toss plugin types that need qt if running without qt
        if not qt_is_safe:
            self.plugin_types = {
                type_name: type_class
                for type_name, type_class in self.plugin_types.items()
                if not getattr(type_class, 'needs_qt', True)
            }

        # Initialize types
        self.type_mapping = {
            type_name: {}
            for type_name in self.plugin_types.keys()
        }
        self._entrypoints = {
            type_name: {}
            for type_name in self.plugin_types.keys()
        }
        self._load_cache = {
            type_name: {}
            for type_name in self.plugin_types.keys()
        }

        # Check if cammart should be ignored
        try:
            args = parse_args(exit_on_fail=False)
            include_cammart = not args.nocammart
            self._blacklist = args.blacklist
        except RuntimeError:
            include_cammart = False

        # ...if so, blacklist it
        if not include_cammart:
            self._blacklist.extend(['cammart', 'venvs'])
Esempio n. 4
0
    def __init__(self):
        super(XicamPluginManager, self).__init__()
        venvsobservers.append(self)

        # Link categories to base classes
        categoriesfilter = {
            "DataHandlerPlugin": DataHandlerPlugin,
            "DataResourcePlugin": DataResourcePlugin,
            "CatalogPlugin": CatalogPlugin,
            "ProcessingPlugin": ProcessingPlugin,
            "Fittable1DModelPlugin": Fittable1DModelPlugin,
        }

        # If xicam.gui is not loaded (running headless), don't load GUIPlugins or WidgetPlugins
        if qt_is_safe:
            categoriesfilter.update({
                "ControllerPlugin":
                ControllerPlugin,
                "GUIPlugin":
                GUIPlugin,
                "WidgetPlugin":
                QWidgetPlugin,
                "SettingsPlugin":
                SettingsPlugin,
                "EZPlugin":
                _EZPlugin,
                "Fittable1DModelPlugin":
                Fittable1DModelPlugin,
            })

        self.blacklist = []
        if "--no-cammart" in sys.argv:
            self.blacklist.extend(['cammart', 'venvs'])

        self.setCategoriesFilter(categoriesfilter)

        # Places to look for plugins
        self.plugindirs = [user_plugin_dir, site_plugin_dir] + list(
            xicam.__path__)

        self.setPluginPlaces(self.plugindirs)
        msg.logMessage("plugindirectories:", *self.plugindirs)

        # Loader thread
        self.loadthread = None
        self.loadqueue = deque()

        self.observers = []

        self.loading = False
        self.loadcomplete = False