Exemplo n.º 1
0
    def __init__(self):
        setup_logging()
        self.extension_id = os.path.basename(os.path.dirname(sys.argv[0]))
        self.logger = logging.getLogger(self.extension_id)
        self._listeners = defaultdict(list)
        self._client = Client(self)
        self.preferences = {}
        try:
            self.preferences = json.loads(
                os.environ.get("EXTENSION_PREFERENCES", "{}"))
        except Exception:
            pass

        if not self.preferences:
            self.logger.error("Could not load user preferences")

        # subscribe with methods if user has added their own
        if self.__class__.on_query_change is not Extension.on_query_change:
            self.subscribe(KeywordQueryEvent, 'on_query_change')
        if self.__class__.on_item_enter is not Extension.on_item_enter:
            self.subscribe(ItemEnterEvent, 'on_item_enter')
        if self.__class__.on_unload is not Extension.on_unload:
            self.subscribe(UnloadEvent, 'on_unload')
        if self.__class__.on_preferences_update is not Extension.on_preferences_update:
            self.subscribe(PreferencesUpdateEvent, 'on_preferences_update')
Exemplo n.º 2
0
 def __init__(self):
     self.extension_id = get_extension_name()
     self._listeners = defaultdict(list)
     self._client = Client(self)
     self.preferences = {}
     self.logger = logging.getLogger(__name__)
     setup_logging()
     # subscribe with methods if user has added their own
     if self.__class__.on_query_change is not Extension.on_query_change:
         self.subscribe(KeywordQueryEvent, self, 'on_query_change')
     if self.__class__.on_item_enter is not Extension.on_item_enter:
         self.subscribe(ItemEnterEvent, self, 'on_item_enter')
     if self.__class__.on_system_exit is not Extension.on_system_exit:
         self.subscribe(SystemExitEvent, self, 'on_system_exit')
     if self.__class__.on_preferences is not Extension.on_preferences:
         self.subscribe(PreferencesEvent, self, 'on_preferences')
     if self.__class__.on_preferences_update is not Extension.on_preferences_update:
         self.subscribe(PreferencesUpdateEvent, self,
                        'on_preferences_update')
Exemplo n.º 3
0
 def __init__(self):
     self._listeners = defaultdict(list)
     self._client = Client(self)
     self.preferences = {}
     self.logger = logging.getLogger(__name__)
     setup_logging()
Exemplo n.º 4
0
 def client(self, extension, framer, sock_client):
     client = Client(extension)
     client.framer = framer
     client.client = sock_client
     return client
Exemplo n.º 5
0
 def client(self, extension):
     return Client(extension,
                   ws_api_url="ws://localhost:5000/test_extension")