def setTree(self, tree): if tree is None: self._rawTree = self._tree = self._selectionProxy = None else: self._rawTree = tree self._tree = getProxyForObject( 1, components.interfaces.nsITreeBoxObject, self._rawTree, PROXY_ALWAYS | PROXY_SYNC) self._selectionProxy = getProxyForObject( 1, components.interfaces.nsITreeSelection, self.selection, PROXY_ALWAYS | PROXY_SYNC)
def notifyChanges(self, changes): observer = self.getAliveObserver() if not observer: # It's been deleted, do not raise notifications return True isDeleted = False #self.log.debug("notifyChanges: changes to path:") #print "notifyChanges: changes to path:", self.path for path, change in changes.items(): #self.log.debug(" Checking change: %x, path: %s", change, path ) # Set isDeleted if we are removing the watched path if change & FS_PATH_WAS_DELETED: if self.path == path: self.__initalized = 4 isDeleted = True elif change == FS_DIR_DELETED and self.isDecendantOfPath(path): #self.log.debug("Deleted parent of watched path") #self.log.debug(" Watched path: %s", self.path) #self.log.debug(" Deleted path: %s", path) self.__initalized = 4 isDeleted = True if self.watch_type == WATCH_FILE: change = FS_FILE_DELETED # we must proxy the observer calls to the UI thread since most instances will # be modifying UI ob = getProxyForObject( 1, components.interfaces.koIFileNotificationObserver, observer, PROXY_ASYNC | PROXY_ALWAYS) ob.fileNotification(self.uri, change) return isDeleted elif change & FS_UNKNOWN: ob = getProxyForObject( 1, components.interfaces.koIFileNotificationObserver, observer, PROXY_ASYNC | PROXY_ALWAYS) ob.fileNotification(self.uri, change) #elif change == FS_DIR_CREATED: # print "FS_DIR_CREATED, send it on? %r" % (self.flags & change) # Check to make sure we are watching for this change if self.flags & change and self.monitorsPath(path): #if change == FS_DIR_CREATED: # print "FS_DIR_CREATED, did send it on" #self.log.debug(" Change met watch criteria and was sent it!") # Check to make sure the directory is the one were watching uri = pathToUri(path) self.log.info(" change: %x, uri: %s", change, uri) # we must proxy the observer calls to the UI thread since most instances will # be modifying UI ob = getProxyForObject( 1, components.interfaces.koIFileNotificationObserver, observer, PROXY_ASYNC | PROXY_ALWAYS) ob.fileNotification(uri, change) return isDeleted
def wait_till_done(fileStatusSvc, check_items, callback): self._processing_done_event.wait(60) # Proxy the notification back to the UI thread. uiCallbackProxy = getProxyForObject( 1, components.interfaces.koIFileStatusCallback, callback, PROXY_ALWAYS | PROXY_ASYNC) uiCallbackProxy.notifyDone()
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))
def open(self, server, port, username, password, path, passive=True): if not self._lock.acquire(blocking=False): self._raiseServerException( "Could not acquire remote connection lock. Multi-threaded access detected!" ) try: self.server = server self.username = username self.password = password if port > 0: self.port = port else: self.port = koRFProtocolDefaultPort[self.protocol] self.passive = passive self.authAttempt = 0 while self.authAttempt < 3: self.authAttempt += 1 self.log.debug("open: s:%s p:%s u:%s", self.server, self.port, self.username) if not self.username or self.authAttempt > 1: # Need at least a username, or the last login attempt # failed, prompt for username and password now. _username = self.username prompter = self if threading.currentThread().name != "MainThread": # Need to proxy to the main thread. prompter = getProxyForObject( 1, components.interfaces.koIRemoteConnection, self, PROXY_ALWAYS | PROXY_SYNC) prompter.promptForUsernameAndPassword(path) if self.authAttempt > 1 and _username != self.username and \ self.protocol in ("sftp", "scp"): # Need to reconnect, see: # http://bugs.activestate.com/show_bug.cgi?id=68773 self.do_close() self.log.debug("open: username changed, reopening the " "connection") self.do_openSocket() if self.authAttempt == 1: # Make the inital socket connection. self.do_openSocket() if self.do_authenticateWithAgent(): self.log.debug("Agent authentication successful.") break if self.do_authenticateWithPassword(): self.log.debug("Password authentication successful.") break # else we had an invalid username/password, let's go round again else: self._raiseServerException("Authentication failed.") self.log.info("%s connection opened on %s:%s for user %s", self.protocol, self.server, self.port, self.username) # Set the caching key now we have the connection open self._cache_key = "%s:%s" % (self.server, self.username) finally: self._lock.release() return 1
def __init__(self): self._lastErrorSvc = components.classes["@activestate.com/koLastErrorService;1"]\ .getService(components.interfaces.koILastErrorService) self.status = self.STATUS_INITIALIZED self.stdin = None self.stdinHandler = None self.stdout = None self.stderr = None self._stdout_thread = None self._stderr_thread = None self._lastPrompt = None self.lastWritePosition = 0 # The io lock is to ensure that multiple waitForIOToFinish() calls do # not intersect, otherwise an exception can be generated in some # circumstances (when the timing is right). self.__io_thread_lock = threading.Lock() registryService = components.classes['@activestate.com/koLanguageRegistryService;1'].\ getService(components.interfaces.koILanguageRegistryService) self.language = registryService.getLanguage('Errors') self._proxyself = getProxyForObject( 1, components.interfaces.koITerminalHandler, self, PROXY_ALWAYS | PROXY_SYNC)
def __init__(self): #print "file status created" self._observerSvc = components.classes["@mozilla.org/observer-service;1"].\ getService(components.interfaces.nsIObserverService) self._observerProxy = getProxyForObject( 1, components.interfaces.nsIObserverService, self._observerSvc, PROXY_ALWAYS | PROXY_ASYNC) self._globalPrefs = components.classes["@activestate.com/koPrefService;1"].\ getService(components.interfaces.koIPrefService).prefs self._fileSvc = \ components.classes["@activestate.com/koFileService;1"] \ .getService(components.interfaces.koIFileService) self._fileNotificationSvc = \ components.classes["@activestate.com/koFileNotificationService;1"].\ getService(components.interfaces.koIFileNotificationService) self._fileNotificationSvcAsyncProxy = getProxyForObject( None, components.interfaces.koIFileNotificationService, self._fileNotificationSvc, PROXY_ALWAYS | PROXY_ASYNC) self.FNS_WATCH_FILE = components.interfaces.koIFileNotificationService.WATCH_FILE self.FNS_WATCH_DIR = components.interfaces.koIFileNotificationService.WATCH_DIR self.FNS_NOTIFY_ALL = components.interfaces.koIFileNotificationService.FS_NOTIFY_ALL self.FNS_FILE_DELETED = components.interfaces.koIFileNotificationService.FS_FILE_DELETED # The reasons why the status service is checking a file(s). self.REASON_BACKGROUND_CHECK = components.interfaces.koIFileStatusChecker.REASON_BACKGROUND_CHECK self.REASON_ONFOCUS_CHECK = components.interfaces.koIFileStatusChecker.REASON_ONFOCUS_CHECK self.REASON_FILE_CHANGED = components.interfaces.koIFileStatusChecker.REASON_FILE_CHANGED self.REASON_FORCED_CHECK = components.interfaces.koIFileStatusChecker.REASON_FORCED_CHECK # Set of files need to be status checked. Each item is a tuple of # (koIFile, url, reason) self._items_to_check = set() # Reason for why an file status update is occuring. self._updateReason = self.REASON_BACKGROUND_CHECK # Set up the set of monitored urls self._monitoredUrls = set() # List of status checkers (file and SCC checkers). self._statusCheckers = [] # Shutdown is used to tell the background status checking thread to stop self.shutdown = 0 # set up the background thread self._thread = None self._tlock = threading.Lock() self._cv = threading.Condition() self._processing_done_event = threading.Event()
def __init__(self): self._fsLock = threading.Lock() # A queue of feature names for which the status has been requested. self._fsQueue = Queue.Queue() # A thread to gather the status of the features named in the Queue. self._fsThread = None self._fsThreadExiting = threading.Event() # Get a schwack of services and components and proxy them all. self._observerSvc = components.classes["@mozilla.org/observer-service;1"].\ getService(components.interfaces.nsIObserverService) self._observerProxy = getProxyForObject( 1, components.interfaces.nsIObserverService, self._observerSvc, PROXY_ALWAYS | PROXY_ASYNC) self._lastErrorSvc = components.classes["@activestate.com/koLastErrorService;1"].\ getService(components.interfaces.koILastErrorService) self._lastErrorProxy = getProxyForObject( 1, components.interfaces.koILastErrorService, self._lastErrorSvc, PROXY_ALWAYS | PROXY_SYNC) self._prefSvc = components.classes["@activestate.com/koPrefService;1"].\ getService(components.interfaces.koIPrefService) self._prefProxy = getProxyForObject( 1, components.interfaces.koIPrefService, self._prefSvc, PROXY_ALWAYS | PROXY_SYNC) self._nodejsInfoEx = components.classes["@activestate.com/koAppInfoEx?app=NodeJS;1"].\ createInstance(components.interfaces.koIAppInfoEx) self._perlInfoEx = components.classes["@activestate.com/koAppInfoEx?app=Perl;1"].\ createInstance(components.interfaces.koIAppInfoEx) self._phpInfoEx = components.classes["@activestate.com/koAppInfoEx?app=PHP;1"].\ createInstance(components.interfaces.koIAppInfoEx) self._pythonInfoEx = components.classes["@activestate.com/koAppInfoEx?app=Python;1"].\ getService(components.interfaces.koIAppInfoEx) self._python3InfoEx = components.classes["@activestate.com/koAppInfoEx?app=Python3;1"].\ getService(components.interfaces.koIAppInfoEx) self._rubyInfoEx = components.classes["@activestate.com/koAppInfoEx?app=Ruby;1"].\ createInstance(components.interfaces.koIAppInfoEx) self._userPath = koprocessutils.getUserEnv()["PATH"].split(os.pathsep) self._observerSvc.addObserver(self, 'xpcom-shutdown', 0) self._observerSvc.addObserver(self, "feature_status_request", 0) self._ignoreExceptions = 0
def removeUISelectedPaths(self): paths = [] for i in range(self.selection.getRangeCount()): start, end = self.selection.getRangeAt(i) for row_idx in range(start, end + 1): paths.append(self._rows[row_idx]["cix_path"]) proxied_tree_view = getProxyForObject( None, components.interfaces.koICodeIntelCatalogsTreeView, self, PROXY_ALWAYS | PROXY_SYNC) return KoCodeIntelCatalogRemover(paths, proxied_tree_view.post_remove)
def __init__(self): self.appInfoEx = components.classes["@activestate.com/koAppInfoEx?app=CPP;1"].\ getService(components.interfaces.koIAppInfoEx) self._lastErrorSvc = components.classes["@activestate.com/koLastErrorService;1"].\ getService(components.interfaces.koILastErrorService) self._prefSvc = components.classes["@activestate.com/koPrefService;1"].\ getService(components.interfaces.koIPrefService) self._prefProxy = getProxyForObject( 1, components.interfaces.koIPrefService, self._prefSvc, PROXY_ALWAYS | PROXY_SYNC)
def __init__(self): self.F_OK = os.F_OK self.R_OK = os.R_OK self.W_OK = os.W_OK self.X_OK = os.X_OK # XXX Should just cache the user env locally. It ain't changin'. self._userEnvSvc = components.classes["@activestate.com/koUserEnviron;1"].\ getService(components.interfaces.koIUserEnviron) self._userEnvProxy = getProxyForObject( 1, components.interfaces.koIUserEnviron, self._userEnvSvc, PROXY_ALWAYS | PROXY_SYNC) self._manager = None
def __init__(self): self._prefSvc = components.classes["@activestate.com/koPrefService;1"].\ getService(components.interfaces.koIPrefService) self._prefsProxy = getProxyForObject(1, components.interfaces.koIPrefService, self._prefSvc, PROXY_ALWAYS | PROXY_SYNC) self._wrapped = WrapObject(self, components.interfaces.nsIObserver) self._prefSvc.prefs.prefObserverService.addObserver(self._wrapped,'xmlCatalogPaths',0); PyDatasetHandlerService.__init__(self) self.reset()
def __init__(self, uiDriver): # uiDriver is a JavaScript instance, so we must *always* proxy any # calls made to this object through the main thread. self.uiDriver = getProxyForObject( 1, # 1 means the main thread. components.interfaces.koIFastOpenUIDriver, uiDriver, PROXY_ALWAYS | PROXY_SYNC) TreeView.__init__(self) #, debug="fastopen") self._tree = None self._selectionProxy = None self.resetHits()
def __init__(self, sessionName, numEntries=50): self.sessionName = sessionName self.numEntries = numEntries try: koHistorySvc = components.classes["@activestate.com/koHistoryService;1"].\ getService(components.interfaces.koIHistoryService) except COMException: self._koHistorySvcProxy = None else: self._koHistorySvcProxy = \ getProxyForObject(1, components.interfaces.koIHistoryService, koHistorySvc, PROXY_SYNC|PROXY_ALWAYS)
def __init__(self): self._prefSvc = components.classes["@activestate.com/koPrefService;1"].\ getService(components.interfaces.koIPrefService) self._prefsProxy = getProxyForObject( 1, components.interfaces.koIPrefService, self._prefSvc, PROXY_ALWAYS | PROXY_SYNC) self._wrapped = WrapObject(self, components.interfaces.nsIObserver) self._prefSvc.prefs.prefObserverService.addObserver( self._wrapped, 'xmlCatalogPaths', 0) PyDatasetHandlerService.__init__(self) self.reset()
def __init__(self): self._runningOperations = [] self._affectedUris = {} self._lockedUris = {} self._lock = threading.Lock() self._observerSvc = components.classes["@mozilla.org/observer-service;1"].\ getService(components.interfaces.nsIObserverService) self._observerProxy = getProxyForObject( 1, components.interfaces.nsIObserverService, self._observerSvc, PROXY_SYNC | PROXY_ALWAYS) # The testing mode variable is used when running python tests from # the command line, as the getProxyForObject results in an object # that never actually calls the callback function. self.__testing_mode = False
def _Serve(self, requestHandler): # requestHandler is a Javascript object with component 'onStuff' # which is a function accepting one argument (string), and returning # a string requestHandlerProxy = getProxyForObject(1L, components.interfaces.svIStuffListener, requestHandler, PROXY_ALWAYS | PROXY_SYNC) try: self.serverConn.listen(1) log.debug('Socket server listening at %d' % self.socketIn[1]) count = 0 connected = False while self.runServer: while self.runServer and self.serverIsUp(): connected = False try: conn, addr = self.serverConn.accept() connected = True conn.setblocking(1) self.serverConn.settimeout(10) count += 1L break except Exception: continue if not connected: continue data_all = '' try: while connected: log.debug('Connected by %s : %d' % addr) data = conn.recv(1024L) # TODO: error: [Errno 10054] data_all += data if (not data) or (data[-1] == '\n'): break except Exception, e: log.error(e.args) conn.close() break conn.shutdown(socket.SHUT_RD) log.debug('conn finished reading') try: result = requestHandlerProxy.onStuff(data_all) except Exception, e: result = e.args[0] log.debug('JS request exception: %s' % result) if (result == None): conn.send('\n') else: conn.send(result + '\n') conn.shutdown(socket.SHUT_RDWR) conn.close() log.debug('conn closed')
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)
def __init__(self): observerSvc = components.classes["@mozilla.org/observer-service;1"].\ getService(components.interfaces.nsIObserverService) self._proxiedObsSvc = getProxyForObject(1, \ components.interfaces.nsIObserverService, \ observerSvc, PROXY_ALWAYS | PROXY_SYNC) self.lastCommand = u'' self.lastResult = u'' self.lastMessage = u'' self.runServer = False self.socketOut = ('localhost', 8888L) self.socketIn = ('localhost', 7777L) self.serverConn = None #self.myUID = uuid1().hex #self.id = 'sv' pass
def runAsync(self): # Important!! # Setup the data notification proxy. As we are running in the thread's # context, we *must* use a proxy when notifying the listener, otherwise # we end up trying to run the listener code in our thread's context # which will cause major problems and likely crash! listenerProxy = getProxyForObject( 1, components.interfaces.pyINTPRequestListener, self._listener, NS_PROXY_SYNC | NS_PROXY_ALWAYS) listenerProxy.onStartRequest(None) # The sleep call is here just so the user has a chance to see the # listenerProxy notification updates. time.sleep(1) s = None context = None status = nsError.NS_OK try: # Setup the UDP socket and connect to the timeserver host. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) data = '\x1b' + 47 * '\0' s.sendto(data, self.time_server) data, address = s.recvfrom(1024) if data: t = struct.unpack('!12I', data)[10] if t == 0: timedata = "Error processing time result." else: timedata = time.ctime(t - self.TIME1970) # Turn the addr (str, num) into a list of strings. context = map(str, address) listenerProxy.onDataAvailable(context, timedata) context = None # The sleep call is here just so the user has a chance to see the # listenerProxy notification updates. time.sleep(2) except Exception, ex: context = str(ex) status = nsError.NS_ERROR_FAILURE
def runAsync(self): # Important!! # Setup the data notification proxy. As we are running in the thread's # context, we *must* use a proxy when notifying the listener, otherwise # we end up trying to run the listener code in our thread's context # which will cause major problems and likely crash! listenerProxy = getProxyForObject( 1, components.interfaces.pyINTPRequestListener, self._listener, NS_PROXY_SYNC | NS_PROXY_ALWAYS ) listenerProxy.onStartRequest(None) # The sleep call is here just so the user has a chance to see the # listenerProxy notification updates. time.sleep(1) s = None context = None status = nsError.NS_OK try: # Setup the UDP socket and connect to the timeserver host. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) data = "\x1b" + 47 * "\0" s.sendto(data, self.time_server) data, address = s.recvfrom(1024) if data: t = struct.unpack("!12I", data)[10] if t == 0: timedata = "Error processing time result." else: timedata = time.ctime(t - self.TIME1970) # Turn the addr (str, num) into a list of strings. context = map(str, address) listenerProxy.onDataAvailable(context, timedata) context = None # The sleep call is here just so the user has a chance to see the # listenerProxy notification updates. time.sleep(2) except Exception, ex: context = str(ex) status = nsError.NS_ERROR_FAILURE
def asyncOpen(self, aListener, aContext): self.debug("asyncOpen") if self._state != self.STATE_INITIALIZED: raise ServerException(nsError.NS_ERROR_ALREADY_OPENED) self._async_type = self.TYPE_ASYNC_OPEN self._listener = getProxyForObject(self._targetThread, components.interfaces.pyISSHStreamListener, aListener, NS_PROXY_SYNC | NS_PROXY_ALWAYS) self._context = aContext self._state = self.STATE_OPENING threadMgr = components.classes["@mozilla.org/thread-manager;1"].\ getService(components.interfaces.nsIThreadManager) self._targetThread = threadMgr.currentThread # Kick off the asynchronous Python thread (this calls the run() method). self.start()
def __run(self, name, aOp, aOpCallback, affected_uris, lock_these_uris): # Add the operation to the list tracking_tuple = (name, aOp, aOpCallback, affected_uris, lock_these_uris) with self._lock: self._runningOperations.append(tracking_tuple) for uri in affected_uris: self._affectedUris[uri] = self._affectedUris.get(uri, 0) + 1 if lock_these_uris: self._lockedUris[uri] = self._lockedUris.get(uri, 0) + 1 # Notify the observers that these uri's have changed. if affected_uris: self._observerProxy.notifyObservers(None, 'file_status', "\n".join(affected_uris)) try: # Run the operation if aOpCallback: try: aOpCallback = getProxyForObject( 1, components.interfaces.koIAsyncCallback, aOpCallback, PROXY_SYNC | PROXY_ALWAYS) except COMException: pass try: aOp.status = self.STATUS_RUNNING data = aOp.run() log.debug("operation run finished, return data: %r", data) except Exception, ex: if aOpCallback: log.debug("operation: %r raised exception: %r", aOp, ex) if isinstance(ex, ServerException): e = ex else: e = ServerException(nsError.NS_ERROR_FAILURE, repr(ex)) aOpCallback.callback(self.RESULT_ERROR, e) else:
def _get_proxied_scimoz_ref(self): scimoz = self._get_scimoz_ref() # Proxy it up and return. return getProxyForObject(1, components.interfaces.ISciMoz, scimoz, PROXY_SYNC | PROXY_ALWAYS)
def addPaths(self, paths): proxied_tree_view = getProxyForObject( None, components.interfaces.koICodeIntelCatalogsTreeView, self, PROXY_ALWAYS | PROXY_SYNC) return KoCodeIntelCatalogAdder(paths, proxied_tree_view.post_add)
def run(self): """Process lint requests serially until told to stop. Before the requested linter is run on a document it is first checked for encoding problems (i.e. encoding is not sufficient for current content). """ TIME_LINTS = False log.info("manager thread: start") while 1: try: # wait for next request request = self.requests.get() # quit if request is the quit sentinel if request is None: log.info("manager thread: quit sentinel") break # process the request if TIME_LINTS: startlint = time.clock() log.info("manager thread: process request: %r", request) try: # Look for encoding errors first. results = self._getEncodingLintResults(request.content, request.encoding) if TIME_LINTS: endencodinglint = time.clock() # If there were no encoding errors, try the # requested linter. if not results.getNumResults() and request.linter: #XXX This is where context-sensitive linting args should # be passed in, but linters don't support this yet. log.debug("manager thread: call linter.lint(request)") try: if self._passesGenericCheck(request): results = request.linter.lint(request) #results = UnwrapObject(request.linter).lint(request) # This makes a red statusbar icon go green, but it # might not be what we always want. # Needs more investigation. #if results is None: # results = koLintResults() except: log.exception("Unexpected error while linting") # This makes a red statusbar icon go green, but it # might not be what we always want. # Needs more investigation. #if results is None: # results = koLintResults() log.debug("manager thread: linter.lint(request) returned") if TIME_LINTS: endlintlint = time.clock() prefset = getProxiedEffectivePrefs(request) if prefset.getBooleanPref("lintEOLs"): # Also look for mixed-line endings warnings. self._addMixedEOLWarnings(results, request.content, request.koDoc.new_line_endings) if TIME_LINTS: endeollint = time.clock() print "lint of '%s': encoding=%.3fs lint=%.3fs eol=%.3fs"\ % (request.koDoc.baseName, endencodinglint-startlint, endlintlint-endencodinglint, endeollint-endlintlint) request.results = results except (ServerException, COMException), ex: request.errorString = str(ex) except: # Any exceptions that are not ServerException or # COMException are unexpected internal errors. try: err = "unexpected internal error checking '%s' with '%s' linter"\ % (request.koDoc.baseName, request.linterType) log.exception(err) request.errorString = err except: err = "Unexpected error in koLintService.run" log.error(err) request.errorString = err else: log.info("manager thread: lint results for uid %s: %r", request.uid, results) # Notify of request completion # Note: this is not guaranteed to properly guard the proxy # call because a context switch could happen in between the # condition check and body. That is ok though. At worst it # will raise an exception that will be trapped just below. # The point is to catch the common case. I am pretty sure # that there is no way to do this properly without going # to great lengths. if not self._shuttingDown: try: # Proxy this so the worker thread can report results on this iface. lintBufferProxy = getProxyForObject(1, components.interfaces.koILintBuffer, request.lintBuffer, PROXY_ALWAYS | PROXY_SYNC) lintBufferProxy.reportResults(request) except COMException, ex: # Ignore this error, which will happen if results # are reported after the buffer has gone away (i.e. # the file owning that buffer was closed): # Traceback (most recent call last): # File "...\koLintService.py", line 370, in run # request.lintBuffer.reportResults(request) # File "<XPCOMObject method 'reportResults'>", line 3, in reportResults # Exception: 0x80570021 () errno = ex.args[0] if errno == 0x80570021: pass else: raise
def set_koDoc(self, val): # Access to the koDoc *must* be from the main thread, otherwise # Komodo may crash! self._koDoc = getProxyForObject(1, components.interfaces.koIDocument, val, PROXY_ALWAYS | PROXY_SYNC)
def set_controller(self, controller): self.controller = getProxyForObject( None, components.interfaces.koIProgressController, controller, PROXY_ALWAYS | PROXY_SYNC) self.controller.set_progress_mode("undetermined") self.start()
def _proxyRowCountChanged(self, fromIndex, rowsChanged): if self._treeProxy is None: self._treeProxy = getProxyForObject( 1, components.interfaces.nsITreeBoxObject, self._tree, PROXY_ALWAYS | PROXY_ASYNC) self._treeProxy.rowCountChanged(fromIndex, rowsChanged)
# # Set timeout to 5 seconds due to bugs 89280 and 88439 self._terminal.waitForIOToFinish(timeout=5) self._terminal = None return retval def waitAsynchronously(self, runTerminationListener): t = threading.Thread(target=_terminalProcessWaiter, args=(self, runTerminationListener)) t.setDaemon(True) t.start() def _terminalProcessWaiter(runProcess, runListener): try: if not runProcess._terminal: # There is no terminal reading the stdout/stderr, so we need to # ensure these io channels still get read in order to stop the # possibility of the process stdout/stderr buffers filling up and # blocking the wait call. runProcess.communicate() if runListener: retval = runProcess.wait(None) except process.ProcessError, ex: retval = ex.errno # Use the error set in the exception. if runListener: listenerProxy = getProxyForObject(1, components.interfaces.koIRunTerminationListener, runListener, PROXY_ALWAYS | PROXY_SYNC) listenerProxy.onTerminate(retval)
def getProxiedEffectivePrefsByName(request, prefName): return getProxyForObject(None, components.interfaces.koIPreferenceSet, request.koDoc.getEffectivePrefsByName(prefName), PROXY_ALWAYS | PROXY_SYNC)