Exemplo n.º 1
0
 def get(self):
     self.sender = GetSender(self.request)
     self.raw_data = putRawData(self.request)
     # self.data_list = putDataList(self.request)
     self.data_list = Data.storeRequest(self.request)
     self.metadata = putMetadata(self.sender, self.raw_data, self.data_list)
     
     assert isinstance(self.response, Response)
     self.response.headers['Content-Type'] = "text/plain"
     for key in self.data_list:
         data = db.get(key)
         self.response.out.write("field:" + data.field + " string:" + data.string + "\n")
Exemplo n.º 2
0
    def get(self):
        self.sender = GetSender(self.request)
        self.raw_data = putRawData(self.request)
        # self.data_list = putDataList(self.request)
        self.data_list = Data.storeRequest(self.request)
        self.metadata = putMetadata(self.sender, self.raw_data, self.data_list)

        assert isinstance(self.response, webapp.Response)
        self.response.headers["Content-Type"] = "text/plain"
        for key in self.data_list:
            data = db.get(key)
            if data.field == "productName":
                self.productName = data.string
            if data.field == "serialNumber":
                self.serialNumber = data.string
            if data.field == "moduleId":
                self.moduleId = data.string

                # self.response.out.write("field:" + data.field + " string:" + data.string + "\n")

        try:
            relays = Relays(self.productName, self.serialNumber, self.moduleId)
            assert isinstance(relays, Relays)
            l = []
            for k, v in relays.iteritems():
                assert isinstance(v, Relay)
                r = {
                    "relayId": v.relayId,
                    # "scheduledDateTime" : v.scheduledDateTime,
                    "scheduledEpoch": nativeToEpoch(v.scheduledDateTime),
                    "expectedState": v.expectedState,
                }
                l.append(r)

            o = {"relayStates": l}

            self.response.out.write(dumps(o))
        except AttributeError, e:
            l = map(lambda key: db.get(key), self.data_list)
            j = dumps(l)
            self.response.out.write(j)
Exemplo n.º 3
0
    def get(self):
        self.sender = GetSender(self.request)
        self.raw_data = putRawData(self.request)
        # self.data_list = putDataList(self.request)
        self.data_list = Data.storeRequest(self.request)
        self.metadata = putMetadata(self.sender, self.raw_data, self.data_list)

        assert isinstance(self.response, webapp.Response)
        self.response.headers['Content-Type'] = "text/plain"
        for key in self.data_list:
            data = db.get(key)
            if data.field == "productName":
                self.productName = data.string
            if data.field == "serialNumber":
                self.serialNumber = data.string
            if data.field == "moduleId":
                self.moduleId = data.string

                #self.response.out.write("field:" + data.field + " string:" + data.string + "\n")

        try:
            relays = Relays(self.productName, self.serialNumber, self.moduleId)
            assert isinstance(relays, Relays)
            l = []
            for k, v in relays.iteritems():
                assert isinstance(v, Relay)
                r = {
                    "relayId": v.relayId,
                    #"scheduledDateTime" : v.scheduledDateTime,
                    "scheduledEpoch": nativeToEpoch(v.scheduledDateTime),
                    "expectedState": v.expectedState
                }
                l.append(r)

            o = {"relayStates": l}

            self.response.out.write(dumps(o))
        except AttributeError, e:
            l = map(lambda key: db.get(key), self.data_list)
            j = dumps(l)
            self.response.out.write(j)