def __init__(self):
        self.wrapped = WrapObject(self, components.interfaces.nsIObserver)

        self._macros = RunningMacros()
        self._standardToolbox = None  # Stores the top-level folder's ID
        self._loadedToolboxes = {}  # Map project uri to top-level folder's id
        self._tbFromExtension = {}  # Map folder ID to a boolean
        self.db = None
        self._inited = False

        self._wrapped = WrapObject(self, components.interfaces.nsIObserver)
        _observerSvc = components.classes["@mozilla.org/observer-service;1"]\
                .getService(components.interfaces.nsIObserverService)
        _observerSvc.addObserver(self._wrapped, "project_renamed", 0)
Exemplo n.º 2
0
    def __init__(self):
        global _gObserverSvc
        observerSvc = components.classes["@mozilla.org/observer-service;1"]\
            .getService(components.interfaces.nsIObserverService)
        _gObserverSvc = getProxyForObject(
            None, components.interfaces.nsIObserverService, observerSvc,
            PROXY_ALWAYS | PROXY_SYNC)

        self._observer = WrapObject(self, components.interfaces.nsIObserver)
        _gObserverSvc.addObserver(self._observer, 'xpcom-shutdown', 1)

        # Platform-specific handle on object indicating Komodo is running.
        self._running = None
        # Commandment reader thread.
        self._reader = None

        if sys.platform.startswith("win"):
            global _gHWnd
            try:
                _gHWnd = koWndWrapper.get_active_window()
            except RuntimeError, ex:
                # XXX This sporadically fails:
                # api_error: (0, 'SetForegroundWindow', 'No error message is available')
                # it happens if you switch windows right at a certain
                # moment during startup.  The problem is then that
                # startup really fails in a lot of ways unless we
                # catch this problem here
                log.error(str(ex))
Exemplo n.º 3
0
 def __init__(self):
     self._files = {}
     self._statuscheck_files = {}
     self._tmpfiles = {}
     self._tmpdirs = {}
     self._uriParser = URIParser()
     self.obsSvc = components.classes["@mozilla.org/observer-service;1"].getService(components.interfaces.nsIObserverService)
     self.obsSvc.addObserver(WrapObject(self,components.interfaces.nsIObserver), "xpcom-shutdown", 0)
Exemplo n.º 4
0
    def __init__(self):
        self._viewMgr = {}
        self.wrapped = WrapObject(
            self, components.interfaces.nsIWindowMediatorListener)

        self.wm = components.classes["@mozilla.org/appshell/window-mediator;1"].\
                        getService(components.interfaces.nsIWindowMediator)
        self.wm.addListener(self.wrapped)
        self._all_views_wr = set()
Exemplo n.º 5
0
    def __init__(self):
        self.wrapped = WrapObject(self, components.interfaces.nsIObserver)

        self._contentUtils = components.classes["@activestate.com/koContentUtils;1"].\
                    getService(components.interfaces.koIContentUtils)

        self._data = {} # Komodo nsIDOMWindow -> KomodoWindowData instance
        self._standardToolbox = None  # Stores the top-level folder's ID
        self._loadedToolboxes = {}    # Map project uri to top-level folder's id
        self._tbFromExtension = {}    # Map folder ID to a boolean
        self._db = None
        self._inited = False
        
        self._wrapped = WrapObject(self, components.interfaces.nsIObserver)
        _observerSvc = components.classes["@mozilla.org/observer-service;1"]\
                .getService(components.interfaces.nsIObserverService)
        _observerSvc.addObserver(self._wrapped,
                                 "project_renamed", 0)
Exemplo n.º 6
0
 def __init__(self):
     self.lock = threading.Condition()
     self.clear()
     observerSvc = components.classes["@mozilla.org/observer-service;1"].\
         getService(components.interfaces.nsIObserverService)
     self.__wrappedSelf = WrapObject(self,
                                     components.interfaces.nsIObserver)
     observerSvc.addObserver(self.__wrappedSelf, 'file_status', 0)
     self.__observing = True
Exemplo n.º 7
0
    def __init__(self):
        log.info("KoLintService.__init__()")

        self._linterCache = {}  # mapping of linterCID to koILinter instance
        self.requests = RequestQueue()  # an item of None is the quit sentinel
        self._shuttingDown = 0
        self.manager = threading.Thread(target=self.run, name="Linter")
        self.manager.setDaemon(True)
        self.manager.start()

        self._wrapped = WrapObject(self, components.interfaces.nsIObserver)
        _observerSvc = components.classes["@mozilla.org/observer-service;1"].\
            getService(components.interfaces.nsIObserverService)
        _observerSvc.addObserver(self._wrapped, 'xpcom-shutdown', 1)

        # dict of { 'terminals' => array of linters, 'aggregators' => array of linters }
        self._linterCIDsByLanguageName = {}
        # Init it now, pay the price of walking through the categories now...
        catman = components.classes["@mozilla.org/categorymanager;1"].\
            getService(components.interfaces.nsICategoryManager)
        categoryName = 'category-komodo-linter-aggregator'
        names = catman.enumerateCategory(categoryName)
        while names.hasMoreElements():
            nameObj = names.getNext()
            rawName, fixedName = self._getCategoryNameFromNameObj(nameObj)
            cid = catman.getCategoryEntry(categoryName, rawName)
            if not self._linterCIDsByLanguageName.has_key(fixedName):
                self._linterCIDsByLanguageName[fixedName] = {
                    'terminals': [],
                    'aggregator': cid
                }
            else:
                log.warn(
                    "Possible Problem: more than one entry for linter aggregator %s (was %s), now %s",
                    name,
                    self._linterCIDsByLanguageName[fixedName]['aggregator'],
                    cid)
                self._linterCIDsByLanguageName[fixedName]['aggregator'] = cid

        categoryName = 'category-komodo-linter'
        names = catman.enumerateCategory(categoryName)
        while names.hasMoreElements():
            nameObj = names.getNext()
            rawName, fixedName = self._getCategoryNameFromNameObj(nameObj)
            idx = fixedName.find("&type=")
            if idx == -1:
                languageName = fixedName
            else:
                languageName = fixedName[:idx]
            cid = catman.getCategoryEntry(categoryName, rawName)
            if not self._linterCIDsByLanguageName.has_key(languageName):
                self._linterCIDsByLanguageName[languageName] = {
                    'terminals': [],
                    'aggregator': None
                }
            self._linterCIDsByLanguageName[languageName]['terminals'].append(
                cid)
Exemplo n.º 8
0
        def __init__(self):
            self._prefSvc = components.classes["@activestate.com/koPrefService;1"].\
                                    getService(components.interfaces.koIPrefService)

            self._wrapped = WrapObject(self, components.interfaces.nsIObserver)
            self._prefSvc.prefs.prefObserverService.addObserver(
                self._wrapped, 'xmlCatalogPaths', 0)

            PyDatasetHandlerService.__init__(self)
            self.reset()
Exemplo n.º 9
0
 def __init__(self):
     koDirSvc = components.classes["@activestate.com/koDirs;1"].\
         getService(components.interfaces.koIDirs)
     db_path = join(koDirSvc.userDataDir, "history.sqlite")
     History.__init__(self, db_path)
     self._observerSvc = components.classes["@mozilla.org/observer-service;1"].\
         getService(components.interfaces.nsIObserverService)
     self._wrapped = WrapObject(self,components.interfaces.nsIObserver)
     
     self._observerSvc.addObserver(self._wrapped, 'xpcom-shutdown', 1)
Exemplo n.º 10
0
 def test_doObserver(self):
     testobserver = TestObserver()
     xpobs = WrapObject(testobserver, components.interfaces.nsIObserver)
     self.observerSvc.addObserver(xpobs, 'test', 0)
     self.observerSvc.notifyObservers(None, 'test', 'Testing')
     assert testobserver.observed == (None, 'test', 'Testing')
     enum = self.observerSvc.enumerateObservers('test')
     assert enum.getNext() == xpobs
     enum = None
     self.observerSvc.removeObserver(xpobs, 'test')
     enum = self.observerSvc.enumerateObservers('test')
     assert not enum.hasMoreElements()
Exemplo n.º 11
0
 def testEmAll(self):
     ob = WrapObject(PythonFailingComponent(),
                     components.interfaces.nsIPythonTestInterfaceExtra)
     self._testit(nsError.NS_ERROR_FAILURE, 0, ob.do_boolean, 0, 0)
     self._testit(nsError.NS_ERROR_NOT_IMPLEMENTED, 0, ob.do_octet, 0, 0)
     self._testit(nsError.NS_ERROR_FAILURE, 1, ob.do_short, 0, 0)
     self._testit(nsError.NS_ERROR_FAILURE, 1, ob.do_unsigned_short, 0, 0)
     self._testit(nsError.NS_ERROR_FAILURE, 0, ob.do_long, 0, 0)
     self._testit(nsError.NS_ERROR_NOT_IMPLEMENTED, 0, ob.do_unsigned_long,
                  0, 0)
     self._testit(nsError.NS_ERROR_NOT_IMPLEMENTED, 0, ob.do_long_long, 0,
                  0)
     self._testit(nsError.NS_ERROR_FAILURE, 1, ob.do_unsigned_long_long, 0,
                  0)
Exemplo n.º 12
0
    def __init__(self):
        koDirSvc = components.classes["@activestate.com/koDirs;1"].\
            getService(components.interfaces.koIDirs)
        db_path = join(koDirSvc.userDataDir, "history.sqlite")
        History.__init__(self, db_path)
        self._observerSvc = components.classes["@mozilla.org/observer-service;1"].\
            getService(components.interfaces.nsIObserverService)
        self._obsSvcProxy = _xpcom.getProxyForObject(
            1, components.interfaces.nsIObserverService, self._observerSvc,
            _xpcom.PROXY_SYNC | _xpcom.PROXY_ALWAYS)


        self._prefSvc = components.classes["@activestate.com/koPrefService;1"].\
            getService(components.interfaces.koIPrefService)
        self._wrapped = WrapObject(self, components.interfaces.nsIObserver)

        self._observerSvc.addObserver(self._wrapped, 'xpcom-shutdown', 1)
Exemplo n.º 13
0
 def evalPythonString(self, code):
     # Ensure the code ends with an empty newline
     code += '\n\n'
     try:
         try:
             result = self._eval_code_and_return_result(code)
             try:
                 # See if the result can be turned into an xpcom object
                 return WrapObject(result, components.interfaces.nsIVariant)
             except ValueError:
                 # else, we'll just return a string representation
                 return repr(result)
         except SyntaxError:
             return self._exec_code_and_get_output(code)
     except Exception, e:
         # Format the exception, removing the exec/eval sections.
         exc_tb = traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)
         return "".join(exc_tb[:1] + exc_tb[3:])
Exemplo n.º 14
0
def test():
    # For the benefit of the test suite, we print some reassuring messages.
    import sys
    sys.__stderr__.write("***** NOTE: Three tracebacks below this is normal\n")
    ob = WrapObject(PythonFailingComponent(),
                    components.interfaces.nsIPythonTestInterfaceExtra)
    _testit(nsError.NS_ERROR_FAILURE, ob.do_boolean, 0, 0)
    _testit(nsError.NS_ERROR_NOT_IMPLEMENTED, ob.do_octet, 0, 0)
    _testit(nsError.NS_ERROR_FAILURE, ob.do_short, 0, 0)
    _testit(nsError.NS_ERROR_FAILURE, ob.do_unsigned_short, 0, 0)
    _testit(nsError.NS_ERROR_FAILURE, ob.do_long, 0, 0)
    _testit(nsError.NS_ERROR_NOT_IMPLEMENTED, ob.do_unsigned_long, 0, 0)
    _testit(nsError.NS_ERROR_NOT_IMPLEMENTED, ob.do_long_long, 0, 0)
    _testit(nsError.NS_ERROR_FAILURE, ob.do_unsigned_long_long, 0, 0)
    print "The xpcom exception tests passed"
    # For the benefit of the test suite, some more reassuring messages.
    sys.__stderr__.write(
        "***** NOTE: Three tracebacks printed above this is normal\n")
    sys.__stderr__.write(
        "*****       It is testing the Python XPCOM Exception semantics\n")
Exemplo n.º 15
0
 def evalAsPython(self, domdocument, window, scimoz, koDoc, view, code,
                  async):
     self._asyncMacroCheck(async)
     projectUtils.evalPythonMacro(
         WrapObject(self, self._com_interfaces_[0]), domdocument, window,
         scimoz, koDoc, view, code)
Exemplo n.º 16
0
class _KoMacroTool(_KoTool):
    _com_interfaces_ = [components.interfaces.koIMacroTool]
    typeName = 'macro'
    prettytype = 'Macro'
    _iconurl = _icons.get('macro')

    def __init__(self, *args):
        _KoTool.__init__(self, *args)
        self.flavors.insert(0, 'text/x-moz-url')
        self.name = "New Macro"
        self._attributes['language'] = 'JavaScript'
        self._attributes['async'] = False
        self._attributes['trigger_enabled'] = False
        self._attributes['trigger'] = ""

    def delete(self):
        try:
            self._getObserverSvc().notifyObservers(self, 'macro-unload', '')
        except Exception:
            pass
        _KoTool.delete(self)

    def updateSelf(self):
        if self.initialized:
            return
        info = _tbdbSvc.getMacroInfo(self.id)
        #log.debug("macro info: %s", info)
        self._finishUpdatingSelf(info)

    def get_url(self):
        if self._attributes['language'] == 'JavaScript':
            ext = ".js"
        elif self._attributes['language'] == 'Python':
            ext = ".py"
        # The important parts are the ID and the extension, so the
        # name itself can be sluggified so the autosave routine
        # doesn't get caught up with special characters in the name.
        return "macro2://%s/%s%s" % (self.id, koToolbox2.slugify(
            self.name), ext)

    def save(self):
        # Write the changed data to the file system
        self.saveContentToDisk()
        _tbdbSvc.saveContent(self.id, self.value)
        _tbdbSvc.saveMacroInfo(self.id, self.name, self.value,
                               self._attributes)
        self._postSave()
        _toolsManager.removeChangedCachedTool(self.id)

    def saveProperties(self):
        # Write the changed data to the file system
        self.saveToolToDisk()
        _tbdbSvc.saveMacroInfo(self.id, self.name, self.value,
                               self._attributes)

    def _asyncMacroCheck(self, async):
        if async:
            lastErrorSvc = components.classes["@activestate.com/koLastErrorService;1"]\
                .getService(components.interfaces.koILastErrorService)
            err = "Asynchronous python macros not yet implemented"
            lastErrorSvc.setLastError(1, err)
            raise ServerException(nsError.NS_ERROR_ILLEGAL_VALUE, err)

    def evalAsPython(self, domdocument, window, scimoz, koDoc, view, code,
                     async):
        self._asyncMacroCheck(async)
        projectUtils.evalPythonMacro(
            WrapObject(self, self._com_interfaces_[0]), domdocument, window,
            scimoz, koDoc, view, code)

    def evalAsPythonObserver(self, domdocument, window, scimoz, koDoc, view,
                             code, async, subject, topic, data):
        self._asyncMacroCheck(async)
        projectUtils.evalPythonMacro(
            WrapObject(self, self._com_interfaces_[0]), domdocument, window,
            scimoz, koDoc, view, code, subject, topic, data)
# The contents of this file are subject to the Mozilla Public License Version
Exemplo n.º 18
0
 def test_noObserversToRemove(self):
     testobserver = TestObserver()
     xpobs = WrapObject(testobserver, components.interfaces.nsIObserver)
     self.observerSvc.removeObserver(xpobs, 'test')
Exemplo n.º 19
0
 def __init__(self):
     self.finalizers = []
     obsvc = components.classes["@mozilla.org/observer-service;1"].\
                 getService(components.interfaces.nsIObserverService)
     self._observer = WrapObject(self, components.interfaces.nsIObserver)
     obsvc.addObserver(self._observer, 'xpcom-shutdown', 1)