예제 #1
0
파일: params.py 프로젝트: baden/api.navi.cc
    def delete(self, skey):
        Params.del_queueall(skey)
        sinform.sinform_unset(skey, "CONFIGUP")

        msg = {
            "message": "cfg_upd",
            "skey": skey
        }
        self.application.publisher.send(msg)
예제 #2
0
    def onget(self):

        cmd = self.get_argument('cmd', '')

        if cmd == "params":
            empty = True
            params = Params.get(self.skey).all()
            for (k, v) in params.iteritems():
                if v.has_key("queue"):
                    self.write("PARAM %s %s\r\n" % (k, v["queue"]))
                    empty = False

            self.write("FINISH\r\n")
            if empty:
                sinform.sinform_unset(self.skey, "CONFIGUP")

        elif cmd == 'cancel':
            Params.del_queueall(self.skey)
            sinform.sinform_unset(self.skey, "CONFIGUP")
            self.write("DELETED\r\n")

            msg = {
                "message": "cfg_upd",
                "skey": self.skey
            }
            self.application.publisher.send(msg)

        elif cmd == 'confirm':
            Params.confirm_queueall(self.skey)
            sinform.sinform_unset(self.skey, "CONFIGUP")
            self.write("CONFIRM")

            msg = {
                "message": "cfg_upd",
                "skey": self.skey
            }
            self.application.publisher.send(msg)

        elif cmd == 'check':
            empty = True
            params = Params.get(self.skey).all()
            for (k, v) in params.iteritems():
                if v.has_key("queue"):
                    empty = False

            if empty:
                sinform.sinform_unset(self.skey, "CONFIGUP")
                self.write('NODATA\r\n')
            else:
                sinform.sinform_set(self.skey, "CONFIGUP")
                self.write("CONFIGUP\r\n")
예제 #3
0
    def onget(self):

        cmd = self.get_argument('cmd', '')

        if cmd == "params":
            empty = True
            params = Params.get(self.skey).all()
            for (k, v) in params.iteritems():
                if v.has_key("queue"):
                    self.write("PARAM %s %s\r\n" % (k, v["queue"]))
                    empty = False

            self.write("FINISH\r\n")
            if empty:
                sinform.sinform_unset(self.skey, "CONFIGUP")

        elif cmd == 'cancel':
            Params.del_queueall(self.skey)
            sinform.sinform_unset(self.skey, "CONFIGUP")
            self.write("DELETED\r\n")

            msg = {"message": "cfg_upd", "skey": self.skey}
            self.application.publisher.send(msg)

        elif cmd == 'confirm':
            Params.confirm_queueall(self.skey)
            sinform.sinform_unset(self.skey, "CONFIGUP")
            self.write("CONFIRM")

            msg = {"message": "cfg_upd", "skey": self.skey}
            self.application.publisher.send(msg)

        elif cmd == 'check':
            empty = True
            params = Params.get(self.skey).all()
            for (k, v) in params.iteritems():
                if v.has_key("queue"):
                    empty = False

            if empty:
                sinform.sinform_unset(self.skey, "CONFIGUP")
                self.write('NODATA\r\n')
            else:
                sinform.sinform_set(self.skey, "CONFIGUP")
                self.write("CONFIGUP\r\n")
예제 #4
0
    def onpost(self):
        from shlex import split
        cmd = self.get_argument('cmd', '')
        if cmd == 'save':
            body = self.request.body

            config = {}
            for conf in body.split("\n"):
                params = split(conf.strip())
                if len(params) == 4:
                    config[params[0]] = {
                        "type": params[1],
                        "value": params[2],
                        "default": params[3]
                    }

            Params().saveconfig(self.skey, config)

            # В оригинале: inform(skey, 'cfgupd', {'skey': str(skey)})
            msg = {"message": "cfg_upd", "skey": self.skey}
            self.application.publisher.send(msg)

            self.write("CONFIG: OK\r\n")
예제 #5
0
파일: params.py 프로젝트: baden/api.navi.cc
 def get(self, skey):
     value = Params.get(skey).all()
     self.writeasjson({
         "skey": skey,
         "value": value,
     })