Attempt to unpack the given data using the specified format. Throws a protocol error if the unpacking fails. @param format Format string to use for unpacking @param data Data to unpack. We _cannot_ unpack strings! @return list of values unpacked, if successful.
(format, data)
| 120 | |
| 121 | |
| 122 | def unpack_response(format, data): |
| 123 | """ |
| 124 | Attempt to unpack the given data using the specified format. Throws a protocol |
| 125 | error if the unpacking fails. |
| 126 | |
| 127 | @param format Format string to use for unpacking |
| 128 | @param data Data to unpack. We _cannot_ unpack strings! |
| 129 | @return list of values unpacked, if successful. |
| 130 | """ |
| 131 | |
| 132 | try: |
| 133 | return struct.unpack(format, buffer(data)) |
| 134 | except struct.error as e: |
| 135 | raise makerbot_driver.errors.ProtocolError("Unexpected data returned from machine. Expected length=%i, got=%i, error=%s" % |
| 136 | (struct.calcsize(format), len(data), str(e))) |
| 137 | |
| 138 | |
| 139 | def unpack_response_with_string(format, data): |
no outgoing calls
no test coverage detected