示例#1
0
    def task_upload(self, state):
        buf = state["buf"]
        xfer_bytes = state["xfer_bytes"]
        xfer_total = state["xfer_total"]

        # Send chunk
        chunk = min(60, xfer_total - xfer_bytes)
        openmv.flash_write(buf[xfer_bytes:xfer_bytes + chunk])

        xfer_bytes += chunk
        state["xfer_bytes"] = xfer_bytes
        state["bar"].set_fraction(xfer_bytes / float(xfer_total))
        state["bar"].set_text("Uploading %d/%d" % (xfer_bytes, xfer_total))

        if (xfer_bytes == xfer_total):
            openmv.bootloader_reset()
            openmv.disconnect()
            return False
        return True
    def task_upload(self, state):
        buf = state["buf"]
        xfer_bytes = state["xfer_bytes"]
        xfer_total = state["xfer_total"]

        # Send chunk
        chunk = min (60, xfer_total-xfer_bytes)
        openmv.flash_write(buf[xfer_bytes : xfer_bytes+chunk])

        xfer_bytes += chunk
        state["xfer_bytes"] = xfer_bytes
        state["bar"].set_fraction(xfer_bytes/float(xfer_total))
        state["bar"].set_text("Uploading %d/%d"%(xfer_bytes, xfer_total))

        if (xfer_bytes == xfer_total):
            openmv.bootloader_reset()
            openmv.disconnect()
            return False
        return True