Пример #1
0
def on_init():
    try:
        spawn_exchangerates_updater()
    except Exception as e:
        logging.error(e)
    finally:
        EventManager.get().removeResponder(on_init)
        EventManager.get().registerResponder(on_idle, "idle")
Пример #2
0
    def __init__(self):
        super(_ForegroundWindowCommand, self).__init__()

        self._foreground_window = None
        self._foreground_window_title = None

        EventManager.get().registerResponder(self.on_quasimode_start,
                                             "startQuasimode")
        atexit.register(self.__finalize)
Пример #3
0
def load():
    import sys
    from enso.contrib.scriptotron.ensoapi import EnsoApi
    sys.path.append(EnsoApi().get_enso_commands_folder())

    ScriptTracker.install( EventManager.get(),
                           CommandManager.get() )
Пример #4
0
def load():
    # Set maximum priority on start
    print "SETTING INITIAL HIGH PRIORITY"
    set_priority(HIGH_PRIORITY)

    # Setup timer to switch back to normal priority after some time
    global on_enso_ready_timer
    on_enso_ready_timer = threading.Timer(ON_ENSO_READY_TIMEOUT, on_enso_ready)
    on_enso_ready_timer.start()

    # Schedule normal priority after init is completed
    # TODO: Not reliable
    #EventManager.get().registerResponder(on_enso_ready, "init")

    # Register key-event reponder for detecting quasimode changes
    EventManager.get().registerResponder(on_quasimode_key, "key")
Пример #5
0
def run():
    """
    Initializes and runs Enso.
    """

    from enso.events import EventManager
    from enso.quasimode import Quasimode
    from enso import plugins, webui
    from enso.quasimode import layout

    # Set color theme before quasimode is loaded to capture font styles
    layout.setColorTheme(config.COLOR_THEME)

    eventManager = EventManager.get()
    Quasimode.install( eventManager )
    plugins.install( eventManager )
    def initEnso():
        msgXml = config.OPENING_MSG_XML
        if msgXml != None:
            messages.displayMessage( msgXml )

        run_tasks()

    if config.ENABLE_WEB_UI:
        webui.start(eventManager)

    eventManager.registerResponder( initEnso, "init" )
    eventManager.run()
Пример #6
0
    def get(cls):
        if not cls.__instance:
            from enso.messages.primarywindow import PrimaryMsgWind
            from enso.messages.miniwindows import MiniMessageQueue
            from enso.events import EventManager

            cls.__instance = cls(EventManager.get(), PrimaryMsgWind, MiniMessageQueue)
        return cls.__instance
Пример #7
0
def cmd_enso(ensoapi, action):
    """ Enso system command
    <b>Actions:</b><br>
    &nbsp;&nbsp- quit - quit Enso<br>
    &nbsp;&nbsp- restart - restart Enso<br>
    &nbsp;&nbsp- refresh - reload shortcuts available for the 'open' command<br>
    &nbsp;&nbsp- settings - open Enso settings page<br>
    &nbsp;&nbsp- commands - open Enso command list<br>
    &nbsp;&nbsp- tasks - open Enso task editor<br>
    &nbsp;&nbsp- editor - open Enso command editor<br>
    &nbsp;&nbsp- about - show application information<br>
    """
    if action == 'quit':
        if not retreat.is_locked():
            EventManager.get().stop()
        else:
            displayMessage(config.BLOCKED_BY_RETREAT_MSG)
    elif action == 'restart':
        if not retreat.is_locked():
            EventManager.get().stop()
            subprocess.Popen(
                [config.ENSO_EXECUTABLE, "--restart " + str(os.getpid())])
        else:
            displayMessage(config.BLOCKED_BY_RETREAT_MSG)
    elif action == 'refresh':
        Shortcuts.get().refreshShortcuts()
        ScriptTracker.get()._reloadPyScripts()
        displayMessage(config.REFRESHING_MSG_XML)
    elif action == 'settings':
        if config.ENABLE_WEB_UI:
            os.startfile("http://" + webui.HOST + ":" + str(webui.PORT) +
                         "/options.html")
    elif action == 'commands':
        if config.ENABLE_WEB_UI:
            os.startfile("http://" + webui.HOST + ":" + str(webui.PORT) +
                         "/commands.html")
    elif action == 'tasks':
        if config.ENABLE_WEB_UI:
            os.startfile("http://" + webui.HOST + ":" + str(webui.PORT) +
                         "/tasks.html")
    elif action == 'editor':
        if config.ENABLE_WEB_UI:
            os.startfile("http://" + webui.HOST + ":" + str(webui.PORT) +
                         "/edit.html")
    elif action == 'about':
        displayMessage(enso.config.ABOUT_BOX_XML)
Пример #8
0
 def __init__(self):
     """
     Initializes the command manager.
     """
     self._current_session_id = None
     self.__caches = {}
     self.__eventManager = EventManager.get()
     self.__eventManager.registerResponder(self._onEndQuasimode,
                                           "endQuasimode")
Пример #9
0
    def get(cls):
        if not cls.__instance:
            from enso.messages.primarywindow import PrimaryMsgWind
            from enso.messages.miniwindows import MiniMessageQueue
            from enso.events import EventManager

            cls.__instance = cls(EventManager.get(), PrimaryMsgWind,
                                 MiniMessageQueue)
        return cls.__instance
Пример #10
0
def run():
    """
    Initializes and runs Enso.
    """
    import logging
    import sys
    from enso.events import EventManager
    from enso.quasimode import Quasimode
    from enso import events, plugins, config, messages, quasimode, webui

    def except_hook(type, value, tback):
        # manage unhandled exception here
        logging.error(value)
        tback.print_exc()
        sys.__excepthook__(type, value, tback)  # then call the default handler

    sys.excepthook = except_hook

    eventManager = EventManager.get()
    Quasimode.install(eventManager)
    plugins.install(eventManager)

    webui_server = webui.start(eventManager)

    if enso.config.SHOW_SPLASH and config.OPENING_MSG_XML:
        eventManager.registerResponder(
            lambda: messages.displayMessage(config.OPENING_MSG_XML), 
            "init")

    try:
        eventManager.run()
    except SystemError as e:
        logging.error(e)
        import traceback
        traceback.print_exc()
        webui_server.stop()
    except SystemExit as e:
        logging.error(e)
        import traceback
        traceback.print_exc()
        webui_server.stop()
    except KeyboardInterrupt:
        webui_server.stop()
    except Exception as e:
        logging.error(e)
        import traceback
        traceback.print_exc()
        webui_server.stop()
    except:
        import traceback
        traceback.print_exc()
        webui_server.stop()
Пример #11
0
 def __init__(self, url_or_request):
     self.url_or_request = url_or_request
     self._connection_pool = None
     self.__eventManager = EventManager.get()
     if isinstance(url_or_request, basestring):
         self._url = url_or_request
         self._headers = DEFAULT_HTTP_HEADERS
     else:
         self._url = url_or_request.get_full_url()
         self._headers = dict(url_or_request.header_items())
     # Force compression if not set by the caller
     # urllib3 auto-decompress the response data based on Content-Encoding header
     if "Accept-Encoding" not in self._headers and "accept-encoding" not in self._headers:
         self._headers["Accept-Encoding"] = "gzip, deflate"
Пример #12
0
def cmd_enso(ensoapi, action):
    """ Enso system command
    <b>Actions:</b><br>
    &nbsp;&nbsp- quit - quit Enso<br>
    &nbsp;&nbsp- restart - restart Enso<br>
    &nbsp;&nbsp- settings - open Enso settings page<br>
    &nbsp;&nbsp- commands - open Enso command list<br>
    &nbsp;&nbsp- task - open Enso task editor<br>
    &nbsp;&nbsp- editor - open Enso command editor<br>
    &nbsp;&nbsp- about - show application information<br>
    """
    if action == 'quit':
        if not retreat.is_locked():
            EventManager.get().stop()
        else:
            displayMessage(config.BLOCKED_BY_RETREAT_MSG)
    elif action == 'restart':
        if not retreat.is_locked():
            EventManager.get().stop()
            subprocess.Popen([config.ENSO_EXECUTABLE, "--restart " + str(os.getpid())])
        else:
            displayMessage(config.BLOCKED_BY_RETREAT_MSG)
    elif action == 'settings':
        if config.ENABLE_WEB_UI:
            os.startfile("http://" + webui.HOST + ":" + str(webui.PORT) + "/options.html")
    elif action == 'commands':
        if config.ENABLE_WEB_UI:
            os.startfile("http://" + webui.HOST + ":" + str(webui.PORT) + "/commands.html")
    elif action == 'tasks':
        if config.ENABLE_WEB_UI:
            os.startfile("http://" + webui.HOST + ":" + str(webui.PORT) + "/tasks.html")
    elif action == 'editor':
        if config.ENABLE_WEB_UI:
            os.startfile("http://" + webui.HOST + ":" + str(webui.PORT) + "/edit.html")
    elif action == 'about':
        displayMessage(enso.config.ABOUT_BOX_XML)
Пример #13
0
        def __init__(self, caller):
            self.caller = caller
            self.polling_interval = max(DEFAULT_SUGGESTIONS_POLLING_INTERVAL, _MINIMAL_SUGGESTIONS_POLLING_INTERVAL)

            self.__suggestion_thread = None
            self.__stop_suggestion_thread = False
            self.__last_text_for_suggestions = None

            self._connection_manager = None

            self._update_queue = Queue()
            self.quasimodeId = 0.0

            self.__eventManager = EventManager.get()

            self._cache_id = None
Пример #14
0
def run():
    """
    Initializes and runs Enso.
    """

    from enso.events import EventManager
    from enso.quasimode import Quasimode
    from enso import events, plugins, config, quasimode

    eventManager = EventManager.get()
    Quasimode.install( eventManager )
    plugins.install( eventManager )

    def showWelcomeMessage():
        msgXml = config.OPENING_MSG_XML
        if msgXml != None:
            messages.displayMessage( msgXml )

    eventManager.registerResponder( showWelcomeMessage, "init" )
    eventManager.run()
Пример #15
0
def run():
    """
    Initializes and runs Enso.
    """

    from enso.events import EventManager
    from enso.quasimode import Quasimode
    from enso import events, plugins, config, quasimode

    eventManager = EventManager.get()
    Quasimode.install(eventManager)
    plugins.install(eventManager)

    def showWelcomeMessage():
        msgXml = config.OPENING_MSG_XML
        if msgXml != None:
            messages.displayMessage(msgXml)

    eventManager.registerResponder(showWelcomeMessage, "init")
    eventManager.run()
Пример #16
0
        def __init__(self, x, y, maxWidth, maxHeight):
            '''Initialize object'''
            gtk.Window.__init__(self, gtk.WINDOW_POPUP)
            self.__x = x
            self.__y = y
            self.__maxWidth = maxWidth
            self.__maxHeight = maxHeight
            self.__width = maxWidth
            self.__height = maxHeight
            self.__surface = None
            self.__opacity = 0xff
            self.__screen_composited = False
            self.__eventMgr = EventManager.get()

            self.set_app_paintable(True)
            self.do_screen_changed()
            self.connect("motion-notify-event", self.on_motion_notify_event)
            self.connect("delete-event", self.ensure_pointer_ungrabbed)

            self.move(self.__x, self.__y)
            self.set_default_size(self.__width, self.__height)
Пример #17
0
        def __init__ (self, x, y, maxWidth, maxHeight):
            '''Initialize object'''
            gtk.Window.__init__ (self, gtk.WINDOW_POPUP)
            self.__x = x
            self.__y = y
            self.__maxWidth = maxWidth
            self.__maxHeight = maxHeight
            self.__width = maxWidth
            self.__height = maxHeight
            self.__surface = None
            self.__opacity = 0xff
            self.__screen_composited = False
            self.__eventMgr = EventManager.get ()

            self.set_app_paintable (True)
            self.do_screen_changed ()
            self.connect ("motion-notify-event", self.on_motion_notify_event)
            self.connect ("delete-event", self.ensure_pointer_ungrabbed)

            self.move (self.__x, self.__y)
            self.set_default_size (self.__width, self.__height)
    def __init__(self, height, position):
        """
        Creates the underlying TransparentWindow and Cairo context.

        Position and height should be in pixels.
        """

        # Use the maximum width that we can, i.e., the desktop width.
        desk_width, desk_height = graphics.getDesktopSize()
        desk_left, desk_top = graphics.getDesktopOffset()

        xPos, yPos = position
        if yPos + height > desk_height:
            pass
        self.__window = TransparentWindow(
            xPos + desk_left, yPos + desk_top, desk_width, desk_height - desk_top - yPos)
        self.__context = self.__window.makeCairoContext()
        self.__is_visible = False
        self.__animatingShow = False
        self.__animatingHide = False
        self.__timeSinceDismissal = 0
        self.__evtManager = EventManager.get()
Пример #19
0
def run():
    """
    Initializes and runs Enso.
    """
    if not started:
        messages.displayMessage("<p>Starting <command>Enso</command>...</p>")

        from enso.events import EventManager
        from enso.quasimode import Quasimode as quasimode
        from enso import events, plugins, config, webui
        global started, webuiServer, eventManager
 
        eventManager = EventManager.get()
        quasimode.install( eventManager )
        plugins.install( eventManager )

        eventManager.registerResponder( showWelcomeMessage, "init" )
        webuiServer = webui.start(eventManager)
        started = True
        try:
            eventManager.run()
        except KeyboardInterrupt, e:
            pass
Пример #20
0
def run():
    """
    Initializes and runs Enso.
    """
    if not started:
        messages.displayMessage("<p>Starting <command>Enso</command>...</p>")

        from enso.events import EventManager
        from enso.quasimode import Quasimode as quasimode
        from enso import events, plugins, config, webui
        global started, webuiServer, eventManager

        eventManager = EventManager.get()
        quasimode.install(eventManager)
        plugins.install(eventManager)

        eventManager.registerResponder(showWelcomeMessage, "init")
        webuiServer = webui.start(eventManager)
        started = True
        try:
            eventManager.run()
        except KeyboardInterrupt, e:
            pass
Пример #21
0
def load():
    ScriptTracker.install(EventManager.get(), CommandManager.get())
Пример #22
0
def cmd_capslock_toggle(ensoapi):
    """ Toggles the current CAPSLOCK state"""
    EventManager.get().setCapsLockMode(GetKeyState(VK_CAPITAL) == 0)
Пример #23
0
def load():
    sys.path.append(EnsoApi().get_enso_commands_folder())

    ScriptTracker.install( EventManager.get(),
                           CommandManager.get() )
Пример #24
0
def load():
    sys.path.append(EnsoApi().get_enso_commands_folder())

    ScriptTracker.install(EventManager.get(), CommandManager.get())
Пример #25
0
def tray_on_enso_quit(systray):
    if not retreat.is_locked():
        EventManager.get().stop()
    else:
        displayMessage(config.BLOCKED_BY_RETREAT_MSG)
Пример #26
0
def tray_on_enso_quit(systray):
    if not retreat.is_locked():
        EventManager.get().stop()
    else:
        displayMessage(config.BLOCKED_BY_RETREAT_MSG)
Пример #27
0
def load():
    import sys
    from enso.contrib.scriptotron.ensoapi import EnsoApi
    sys.path.append(EnsoApi().get_enso_commands_folder())

    ScriptTracker.install(EventManager.get(), CommandManager.get())
Пример #28
0
def cmd_capslock_toggle(ensoapi):
    """ Toggles the current CAPSLOCK state"""
    EventManager.get().setCapsLockMode(GetKeyState(VK_CAPITAL) == 0) 
Пример #29
0
        logging.error("Error spawning exchangerates_updater process: %s", e)
        return 0
    finally:
        reset_update_check_time()


def on_idle(idle_seconds):
    if idle_seconds != CURRENCY_RATES_CHECK_AFTER_IDLE:
        return

    if not is_update_check_due():
        return

    try:
        spawn_exchangerates_updater()
    except Exception as e:
        logging.error(e)


def on_init():
    try:
        spawn_exchangerates_updater()
    except Exception as e:
        logging.error(e)
    finally:
        EventManager.get().removeResponder(on_init)
        EventManager.get().registerResponder(on_idle, "idle")


EventManager.get().registerResponder(on_init, "init")
Пример #30
0
 def __finalize(self):
     EventManager.get().removeResponder(self.on_quasimode_start)
Пример #31
0
def load():
    ScriptTracker.install( EventManager.get(),
                           CommandManager.get() )