def update(self, position, sensors):
        if self.running:
            data = {
                'timestamp': self.timestamp(),
                'position': position,
                'leftSonar': sensors.get_sensor('LeftSonar'),
                'rightSonar': sensors.get_sensor('RightSonar')
            }
            jstr = json.dumps(data)

            self.update_count = self.update_count + 1
            img_bin = self.take_photo()
            img_filename = self.photo_filename()
            params = [('sensordata', jstr),
                      ('update_seq', str(self.update_count))]
            files = [('fileupload', img_filename, img_bin)]

            (code, response_text) = post_multipart(self.host, self.port, '/',
                                                   params, files)
            if code == 200:
                self.logger.debug(
                    "Update sent successfully, file = {}".format(img_filename))
            else:
                self.logger.error(
                    "Unable to send file {filename} got error code {code} with text {text}"
                    .format(filename=img_filename,
                            code=code,
                            text=response_text))
Beispiel #2
0
def main(argv):
    this_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
    nao_rel = '../../../../../data/NAO-Robot.jpg'
    nao_abs = os.path.join(this_dir, nao_rel)
    
    params = [('sensordata', 'json goes here')]
    files = [('fileupload', os.path.basename(nao_abs), open(nao_abs, "rb").read())]

    result = post_multipart("localhost", 8080, '/', params, files)
    print result
Beispiel #3
0
def main(argv):
    this_dir = os.path.dirname(
        os.path.abspath(inspect.getfile(inspect.currentframe())))
    nao_rel = '../../../../../data/NAO-Robot.jpg'
    nao_abs = os.path.join(this_dir, nao_rel)

    params = [('sensordata', 'json goes here')]
    files = [('fileupload', os.path.basename(nao_abs), open(nao_abs,
                                                            "rb").read())]

    result = post_multipart("localhost", 8080, '/', params, files)
    print result
Beispiel #4
0
    def update(self, position, sensors):
        if self.running:
            data = { 'timestamp' : self.timestamp(),
                     'position' : position,
                     'leftSonar' : sensors.get_sensor('LeftSonar'),
                     'rightSonar' : sensors.get_sensor('RightSonar') }
            jstr = json.dumps(data)
        
            self.update_count = self.update_count + 1
            img_bin = self.take_photo()
            img_filename = self.photo_filename()
            params = [('sensordata', jstr),
                      ('update_seq', str(self.update_count))]
            files = [('fileupload', img_filename, img_bin)]

            (code, response_text) = post_multipart(self.host, self.port, '/', params, files)
            if code == 200:
                self.logger.debug("Update sent successfully, file = {}".format(img_filename))
            else:
                self.logger.error("Unable to send file {filename} got error code {code} with text {text}"
                                  .format(filename=img_filename, code=code, text=response_text))