def handleConnected(self): """ Implements abstract method of :class:`WebSocket` * Appends `self` to `self.controllers` * Validates manifest file. * Sends :class:`PreferencesEvent` to extension """ self.extension_id = self.request.path[1:] if not self.extension_id: raise Exception('Incorrect path %s' % self.request.path) logger.info('Extension "%s" connected', self.extension_id) self.manifest = ExtensionManifest.open(self.extension_id) try: self.manifest.validate() except ExtensionManifestError as e: logger.warning("Couldn't connect '%s'. %s: %s", self.extension_id, type(e).__name__, e) self.close() return self.preferences = ExtensionPreferences.create_instance(self.extension_id) self.controllers[self.extension_id] = self self._debounced_send_event = debounce(self.manifest.get_option('query_debounce', 0.05))(self._send_event) self._send_event(PreferencesEvent(self.preferences.get_dict()))
def run(self, extension_id): """ * Validates manifest * Runs extension in a new process :rtype: :class:`threading.Thread` """ if self.is_running(extension_id): raise ExtensionIsRunningError('Extension ID: %s' % extension_id) manifest = ExtensionManifest.open(extension_id) manifest.validate() manifest.check_compatibility() run_process = run_async(daemon=True)(self._run_process) run_process(extension_id)
def test_open__manifest_file__is_read(self, ext_dir): manifest = ExtensionManifest.open('test_extension', ext_dir) assert manifest.get_name() == "Test Extension"
def test_open__manifest_file__is_read(self, ext_dir): manifest = ExtensionManifest.open('test_extension', ext_dir) assert manifest.get_name() == "Test Extension"
def create_instance(cls, ext_id): return cls(ext_id, ExtensionManifest.open(ext_id))