def handleevent(self, msg):
        ''' Handle an Event Message used to start, stop, restart, or validate
            a service on a given node.
        '''
        eventtype = msg.gettlv(coreapi.CORE_TLV_EVENT_TYPE)
        nodenum = msg.gettlv(coreapi.CORE_TLV_EVENT_NODE)
        name = msg.gettlv(coreapi.CORE_TLV_EVENT_NAME)
        try:
            node = self.session.obj(nodenum)
        except KeyError:
            self.session.warn("Ignoring event for service '%s', unknown node " \
                              "'%s'" % (name, nodenum))
            return
            
        fail = ""
        services,unknown = self.servicesfromopaque(name, nodenum)
        for s in services:
            if eventtype == coreapi.CORE_EVENT_STOP or \
                eventtype == coreapi.CORE_EVENT_RESTART:
                status = self.stopnodeservice(node, s)
                if status != "0":
                    fail += (s._name) % "Stop %s,"
            if eventtype == coreapi.CORE_EVENT_START or \
                eventtype == coreapi.CORE_EVENT_RESTART:
                if s._custom:
                    cmds = s._startup
                else:
                    cmds = s.getstartup(node, services)
                if len(cmds) > 0:
                    for cmd in cmds:
                        try:
                            #node.cmd(shlex.split(cmd),  wait = False)
                            status = node.cmd(shlex.split(cmd), wait = True)
                            if status != 0:
                                fail += "Start %s(%s)," % (s._name, cmd)
                        except:
                            node.warn("error starting command %s" % cmd)
                            fail += "Start %s," % (s._name)
            if eventtype == coreapi.CORE_EVENT_PAUSE:
                status = self.validatenodeservice(node, s, services)
                if status != 0:
                    fail += "%s," % (s._name)
            if eventtype == coreapi.CORE_EVENT_RECONFIGURE:
                if s._custom:
                    cfgfiles = s._configs
                else:
                    cfgfiles = s.getconfigfilenames(node.objid,  services)
                if len(cfgfiles) > 0:
                    for filename in cfgfiles:
                        if filename[:7] == "file:///":
                            raise NotImplementedError  # TODO
                        cfg = self.getservicefiledata(s, filename)
                        if cfg is None:
                            cfg = s.generateconfig(node, filename, services)
                        try:
                            node.nodefile(filename, cfg)
                        except:
                            self.warn("error in configure file: %s" % filename)
                            fail += "%s," % (s._name)

        fdata = ""
        if len(fail) > 0:
            fdata += "Fail:" + fail
        udata = ""
        num  = len(unknown)
        if num > 0:
            for u in unknown:
                udata += u
                if num > 1:
                    udata += ", "
                num -= 1
            self.session.warn("Event requested for unknown service(s): %s" % udata);
            udata = "Unknown:" + udata

        tlvdata = ""
        tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_NODE,
                                             nodenum)
        tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_TYPE,
                                             eventtype)
        tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_NAME,
                                             name)
        tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_DATA,
                                             fdata + ";" + udata)
        msg = coreapi.CoreEventMessage.pack(0, tlvdata)
        try:
            self.session.broadcastraw(None, msg)
        except Exception, e:
            self.warn("Error sending Event Message: %s" % e)
dataset/ETHPy150Open coreemu/core/daemon/core/service.py/CoreServices.handleevent/swapped operands of `%`