Пример #1
0
 def __init__(self):
     netsvc.Service.__init__(self, "SEED")
     self._count = 0
     time = netsvc.DateTime()
     data = {"time": time}
     self.publishReport("init", data, -1)
     self.startTimer(self.publish, 1, "1")
Пример #2
0
 def publish(self, name):
     self._count = self._count + 1
     time = netsvc.DateTime()
     value = int(0xFFFF * random.random())
     data = {"time": time, "count": self._count, "value": value}
     self.publishReport("next", data)
     self.startTimer(self.publish, 1, "1")
Пример #3
0
    def handleReport(self, report):
        details = {}

        details["TIMESTAMP"] = netsvc.DateTime()
        details["EVENT"] = "REPORT"
        details["ADDRESS"] = report.publisher().serviceAddress()
        details["SERVICE"] = report.publisher().serviceName()
        details["AGENT"] = report.publisher().agentIdentity()
        details["SUBJECT"] = report.subjectName()
        details["CONTENT"] = report.content()

        self._events.append(details)

        self._version = self._version + 1
Пример #4
0
    def _processAnnouncements(self, binding, group, status):
        details = {}

        details["TIMESTAMP"] = netsvc.DateTime()
        details["BINDING"] = binding
        details["GROUP"] = group

        if status == netsvc.SERVICE_AVAILABLE:
            details["STATUS"] = "AVAILABLE"
        else:
            details["STATUS"] = "WITHDRAWN"

        self._events.append(details)

        self._version = self._version + 1
Пример #5
0
    def handlePublisherNotification(self, notification):
        details = {}

        details["TIMESTAMP"] = netsvc.DateTime()
        details["EVENT"] = "ANNOUNCEMENT"
        details["ADDRESS"] = notification.publisher().serviceAddress()
        details["SERVICE"] = notification.publisher().serviceName()
        details["AGENT"] = notification.publisher().agentIdentity()

        if notification.status() == netsvc.SERVICE_AVAILABLE:
            details["STATUS"] = "AVAILABLE"
        else:
            details["STATUS"] = "WITHDRAWN"

        self._events.append(details)

        self._version = self._version + 1
Пример #6
0
 def log(self, remote_ip, request_time, the_request, status, bytes):
     self.publishReport("request",
                        (remote_ip, netsvc.DateTime(request_time),
                         the_request, status, bytes))
     print '%s %s "%s" %d %d' % (remote_ip, netsvc.DateTime(request_time),
                                 the_request, status, bytes)
    def _subscribeService(self):
        if self._monitor is not None:
            job = netsvc.Job(self._monitor.destroyAgent)
            netsvc.Dispatcher().schedule(job, netsvc.STANDARD_JOB)
            self._monitor = None

        if self._service != "":
            self._subjectView.clear()
            self._subjects = {}

            message = []
            message.append("TIMESTAMP = %s" % ` str(netsvc.DateTime()) `)
            message.append("EVENT     = 'UNSUBSCRIBE'")
            message.append("SERVICE   = %s" % ` self._service `)
            if self._identity != "":
                message.append("IDENTITY  = %s" % ` self._identity `)
            message.append("SUBJECT   = %s" % ` self._subject `)
            message.append("")
            message.append("")
            message = string.joinfields(message, "\n")
            self._appendLog(message)

            self._service = self._serviceField.get()
            self._identity = self._identityField.get()
            self._subject = self._subjectField.get()

            if self._service != "":
                message = []
                message.append("TIMESTAMP = %s" % ` str(netsvc.DateTime()) `)
                message.append("EVENT     = 'SUBSCRIBE'")
                message.append("SERVICE   = %s" % ` self._service `)
                if self._identity != "":
                    message.append("IDENTITY  = %s" % ` self._identity `)
                message.append("SUBJECT   = %s" % ` self._subject `)
                message.append("")
                message.append("")
                message = string.joinfields(message, "\n")
                self._appendLog(message)

                self._monitor = ReportService(self._service, self._identity,
                                              self._subject)
                self._monitor.scheduleStartup()
                self._version = 0
        else:
            self._service = self._serviceField.get()
            self._identity = self._identityField.get()
            self._subject = self._subjectField.get()
            if self._service != "":
                message = []
                message.append("TIMESTAMP = %s" % ` str(netsvc.DateTime()) `)
                message.append("EVENT     = 'SUBSCRIBE'")
                message.append("SERVICE   = %s" % ` self._service `)
                if self._identity != "":
                    message.append("IDENTITY  = %s" % ` self._identity `)
                message.append("SUBJECT   = %s" % ` self._subject `)
                message.append("")
                message.append("")
                message = string.joinfields(message, "\n")
                self._appendLog(message)

                self._monitor = ReportService(self._service, self._identity,
                                              self._subject)
                self._monitor.scheduleStartup()
                self._version = 0