def _widgetDestroyed(self, *args):
     if self._timer:
         self.after_cancel(self._timer)
         self._timer = None
     if self._monitor is not None:
         job = netsvc.Job(self._monitor.destroyAgent)
         netsvc.Dispatcher().schedule(job, netsvc.STANDARD_JOB)
         self._monitor = None
Example #2
0
    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

        self._service = self._serviceField.get()

        self._monitor = AgentMonitor(self._service)
        self._monitor.scheduleStartup()
        self._version = 0
def run(window):
    try:
        dispatcher = netsvc.Dispatcher()

        dispatcher.disableWarnings()

        dispatcher.monitor(signal.SIGINT)

        root = Pmw.initialise()
        root.withdraw()

        main = window(root)

        root.update()

        target = sys.argv[1]

        try:
            group = ""
            group, address = string.splitfields(target, '@')
        except:
            host, port = string.splitfields(target, ':')
        else:
            host, port = string.splitfields(address, ':')

        exchange = netsvc.Exchange(netsvc.EXCHANGE_CLIENT, group)
        exchange.connect(host, int(port), 5)

        reaper = Reaper(root)

        dispatcher.task().start()

        root.deiconify()
        root.update_idletasks()

        root.mainloop()

    finally:
        dispatcher.task().stop()
        dispatcher.task().wait()
Example #4
0
# The exchange process which everything connects to.

import netsvc
import signal

dispatcher = netsvc.Dispatcher()
dispatcher.monitor(signal.SIGINT)

exchange = netsvc.Exchange(netsvc.EXCHANGE_SERVER)
exchange.listen(11111)

dispatcher.run()

# Service which periodically publishes information.

import netsvc
import signal
import random


class Publisher(netsvc.Service):
    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")

    def publish(self, name):
        self._count = self._count + 1
    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