Example #1
0
class Tailer(Window):
    def __init__(self, args):
        title = "Tail '%s'" % args
        self._query = args
        self._lastId = None
        self._results = ResultsListbox()
        self.interval = 2
        self._url = "http://%s/XMLRPC" % console.host
        self._user = console.username
        self._pass = console.password
        self._delayed = None
        self._deferred = None
        logger.debug("using proxy url %s" % self._url)
        Window.__init__(self, title, self._results)

    def startService(self):
        Window.startService(self)
        logger.debug("started tail: using query '%s'" % self._query)
        self._proxy = Proxy(self._url,
                            user=self._user,
                            password=self._pass,
                            allowNone=True)
        self._tail()

    def stopService(self):
        if self._delayed != None:
            self._delayed.cancel()
        self._delayed = None
        if self._deferred != None:
            self._deferred.cancel()
        self._deferred = None
        logger.debug("stopped tail")
        Window.stopService(self)

    def _tail(self):
        self._deferred = self._proxy.callRemote('tailEvents', self._query,
                                                self._lastId)
        self._deferred.addCallback(self._getResult)
        self._deferred.addErrback(self._getError)

    @useMainThread
    def _getResult(self, results):
        """
        Append each search result into the ResultsListbox.
        """
        try:
            meta = results.pop(0)
            self._lastId = meta['lastId']
            logger.debug("tail returned %i results, last id is %s" %
                         (len(results), self._lastId))
            if len(results) > 0:
                for evid, defaultfield, defaultvalue, fields in results:
                    evid = EVID(evid[0], evid[1])
                    self._results.append(evid, defaultfield, defaultvalue,
                                         fields)
                console.redraw()
            from twisted.internet import reactor
            self._delayed = reactor.callLater(self.interval, self._tail)
        except Exception, e:
            logger.exception(e)
Example #2
0
 def __init__(self, args):
     # configure the searcher
     title = "Search results for '%s'" % args
     self._query = args
     self._results = ResultsListbox()
     self._url = "http://%s/XMLRPC" % console.host
     self._user = console.username
     self._pass = console.password
     self._deferred = None
     Window.__init__(self, title, self._results)
Example #3
0
class Tailer(Window):
    def __init__(self, args):
        title = "Tail '%s'" % args
        self._query = args
        self._lastId = None
        self._results = ResultsListbox()
        self.interval = 2
        self._url = "http://%s/XMLRPC" % console.host
        self._user = console.username
        self._pass = console.password
        self._delayed = None
        self._deferred = None
        logger.debug("using proxy url %s" % self._url)
        Window.__init__(self, title, self._results)

    def startService(self):
        Window.startService(self)
        logger.debug("started tail: using query '%s'" % self._query)
        self._proxy = Proxy(self._url, user=self._user, password=self._pass, allowNone=True)
        self._tail()

    def stopService(self):
        if self._delayed != None:
            self._delayed.cancel()
        self._delayed = None
        if self._deferred != None:
            self._deferred.cancel()
        self._deferred = None
        logger.debug("stopped tail")
        Window.stopService(self)

    def _tail(self):
        self._deferred = self._proxy.callRemote('tailEvents', self._query, self._lastId)
        self._deferred.addCallback(self._getResult)
        self._deferred.addErrback(self._getError)

    @useMainThread
    def _getResult(self, results):
        """
        Append each search result into the ResultsListbox.
        """
        try:
            meta = results.pop(0)
            self._lastId = meta['lastId']
            logger.debug("tail returned %i results, last id is %s" % (len(results), self._lastId))
            if len(results) > 0:
                for evid,defaultfield,defaultvalue,fields in results:
                    evid = EVID(evid[0], evid[1])
                    self._results.append(evid, defaultfield, defaultvalue, fields)
                console.redraw()
            from twisted.internet import reactor
            self._delayed = reactor.callLater(self.interval, self._tail)
        except Exception, e:
            logger.exception(e)
Example #4
0
 def __init__(self, args):
     title = "Tail '%s'" % args
     self._query = args
     self._lastId = None
     self._results = ResultsListbox()
     self.interval = 2
     self._url = "http://%s/XMLRPC" % console.host
     self._user = console.username
     self._pass = console.password
     self._delayed = None
     self._deferred = None
     logger.debug("using proxy url %s" % self._url)
     Window.__init__(self, title, self._results)
Example #5
0
 def __init__(self, args):
     # configure the searcher
     title = "Search results for '%s'" % args
     self._query = args
     self._results = ResultsListbox()
     self._url = "http://%s/XMLRPC" % console.host
     self._user = console.username
     self._pass = console.password
     self._deferred = None
     Window.__init__(self, title, self._results)
Example #6
0
 def __init__(self, args):
     title = "Tail '%s'" % args
     self._query = args
     self._lastId = None
     self._results = ResultsListbox()
     self.interval = 2
     self._url = "http://%s/XMLRPC" % console.host
     self._user = console.username
     self._pass = console.password
     self._delayed = None
     self._deferred = None
     logger.debug("using proxy url %s" % self._url)
     Window.__init__(self, title, self._results)
Example #7
0
class Searcher(Window):
    def __init__(self, args):
        # configure the searcher
        title = "Search results for '%s'" % args
        self._query = args
        self._results = ResultsListbox()
        self._url = "http://%s/XMLRPC" % console.host
        self._user = console.username
        self._pass = console.password
        self._deferred = None
        Window.__init__(self, title, self._results)

    def startService(self):
        Window.startService(self)
        logger.debug("started search")
        self.reload()

    def stopService(self):
        if self._deferred != None:
            self._deferred.cancel()
        self._deferred = None
        logger.debug("stopped search")
        Window.stopService(self)

    @useMainThread
    def _getResult(self, result):
        """
        Append each search result into the ResultsListbox.
        """
        try:
            self._meta = result['meta']
            data = result['data']
            for evid,defaultfield,defaultvalue,fields in data:
                evid = EVID(evid[0], evid[1])
                self._results.append(evid, defaultfield, defaultvalue, fields)
            console.redraw()
        except Exception, e:
            logger.exception(e)
Example #8
0
class Searcher(Window):
    def __init__(self, args):
        # configure the searcher
        title = "Search results for '%s'" % args
        self._query = args
        self._results = ResultsListbox()
        self._url = "http://%s/XMLRPC" % console.host
        self._user = console.username
        self._pass = console.password
        self._deferred = None
        Window.__init__(self, title, self._results)

    def startService(self):
        Window.startService(self)
        logger.debug("started search")
        self.reload()

    def stopService(self):
        if self._deferred != None:
            self._deferred.cancel()
        self._deferred = None
        logger.debug("stopped search")
        Window.stopService(self)

    @useMainThread
    def _getResult(self, result):
        """
        Append each search result into the ResultsListbox.
        """
        try:
            self._meta = result['meta']
            data = result['data']
            for evid, defaultfield, defaultvalue, fields in data:
                evid = EVID(evid[0], evid[1])
                self._results.append(evid, defaultfield, defaultvalue, fields)
            console.redraw()
        except Exception, e:
            logger.exception(e)
Example #9
0
class Outfile(Window):
    def __init__(self, args):
        self._path = os.path.expanduser(args)
        title = "Results from file %s" % self._path
        self._results = ResultsListbox()
        Window.__init__(self, title, self._results)

    def startService(self):
        logger.debug("startService")
        try:
            # load data from path
            with file(self._path, 'r') as f:
                logger.debug("opened outfile %s" % self._path)
                reader = DictReader(f)
                for row in reader:
                    self._results.append(row)
                console.redraw()
        except BaseException, e:
            # close the search window
            console.switcher.closeWindow(console.switcher.findWindow(self))
            # display the error on screen
            errtext = "Load failed: %s" % str(e)
            console.error(errtext)
            logger.debug(errtext)
Example #10
0
 def __init__(self, args):
     self._path = os.path.expanduser(args)
     title = "Results from file %s" % self._path
     self._results = ResultsListbox()
     Window.__init__(self, title, self._results)