| Index: embios/trunk/tools/embios.py |
| — | — | @@ -177,7 +177,7 @@ |
| 178 | 178 | create a function with the name of it in this class and decorate
|
| 179 | 179 | it with the decorator @command. If you don't want to call the desired
|
| 180 | 180 | function (wrong arguments etc) just raise ArgumentError with or
|
| 181 | | - without an error message or raise ArgumentCountError
|
| | 181 | + without an error message.
|
| 182 | 182 | """
|
| 183 | 183 | def __init__(self):
|
| 184 | 184 | self.logger = Logger()
|
| — | — | @@ -195,9 +195,9 @@ |
| 196 | 196 | if func in self.cmddict:
|
| 197 | 197 | try:
|
| 198 | 198 | self.cmddict[func](*args)
|
| 199 | | - except ArgumentError, e:
|
| | 199 | + except (ArgumentError, libembios.ArgumentError), e:
|
| 200 | 200 | usage(e, specific=func)
|
| 201 | | - except ArgumentError:
|
| | 201 | + except (ArgumentError, libembios.ArgumentError):
|
| 202 | 202 | usage("Syntax Error in function '" + func + "'", specific=func)
|
| 203 | 203 | except ArgumentTypeError, e:
|
| 204 | 204 | usage(e, specific=func)
|
| — | — | @@ -205,15 +205,14 @@ |
| 206 | 206 | self.logger.error("This function is not implemented yet!")
|
| 207 | 207 | except libembios.DeviceError, e:
|
| 208 | 208 | self.logger.error(str(e))
|
| 209 | | - except ValueError:
|
| 210 | | - usage(specific=func)
|
| 211 | 209 | except TypeError, e:
|
| | 210 | + # Only act on TypeErrors for the function we called, not on TypeErrors raised by another function.
|
| 212 | 211 | if str(e).split(" ", 1)[0] == func + "()":
|
| 213 | 212 | self.logger.error(usage("Argument Error in '" + func + "': Wrong argument count", specific=func))
|
| 214 | 213 | else:
|
| 215 | 214 | raise
|
| 216 | 215 | except libembios.usb.core.USBError:
|
| 217 | | - self.logger.error("Problem with USB connection.")
|
| | 216 | + self.logger.error("There is a problem with the USB connection.")
|
| 218 | 217 | else:
|
| 219 | 218 | usage("No such command")
|
| 220 | 219 |
|
| Index: embios/trunk/tools/libembios.py |
| — | — | @@ -229,7 +229,7 @@ |
| 230 | 230 | """ Writes data to an i2c slave """
|
| 231 | 231 | size = len(data)
|
| 232 | 232 | if size > 256 or size < 1:
|
| 233 | | - raise ValueError("Size must be a number between 1 and 256")
|
| | 233 | + raise ArgumentError("Size must be a number between 1 and 256")
|
| 234 | 234 | if size == 256:
|
| 235 | 235 | size = 0
|
| 236 | 236 | return self.lib.monitorcommand(struct.pack("IBBBBII%ds" % size, 9, index, slaveaddr, startaddr, size, 0, 0, data), "III", (None, None, None))
|
| — | — | @@ -371,15 +371,15 @@ |
| 372 | 372 | elif threadtype == "system":
|
| 373 | 373 | threadtype = 1
|
| 374 | 374 | else:
|
| 375 | | - raise ValueError("Threadtype must be either 'system' or 'user'")
|
| | 375 | + raise ArgumentError("Threadtype must be either 'system' or 'user'")
|
| 376 | 376 | if priority > 256 or priority < 0:
|
| 377 | | - raise ValueError("Priority must be a number between 0 and 256")
|
| | 377 | + raise ArgumentError("Priority must be a number between 0 and 256")
|
| 378 | 378 | if state == "ready":
|
| 379 | 379 | state = 0
|
| 380 | 380 | elif state == "suspended":
|
| 381 | 381 | state = 1
|
| 382 | 382 | else:
|
| 383 | | - raise ValueError("State must be either 'ready' or 'suspended'")
|
| | 383 | + raise ArgumentError("State must be either 'ready' or 'suspended'")
|
| 384 | 384 | resp = self.lib.monitorcommand(struct.pack("IIIIIIII", 19, nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state), "III", (id, None, None))
|
| 385 | 385 | if resp.id < 0:
|
| 386 | 386 | raise DeviceError("The device returned the error code "+str(resp.id))
|
| — | — | @@ -398,10 +398,10 @@ |
| 399 | 399 | try:
|
| 400 | 400 | appheader = struct.unpack("<8sIIIIIIIIII", app[:48])
|
| 401 | 401 | except struct.error:
|
| 402 | | - raise ArgumentError("The specified file is not an emBIOS application")
|
| | 402 | + raise ArgumentError("The specified app is not an emBIOS application")
|
| 403 | 403 | header = appheader[0]
|
| 404 | 404 | if header != "emBIexec":
|
| 405 | | - raise ArgumentError("The specified file is not an emBIOS application")
|
| | 405 | + raise ArgumentError("The specified app is not an emBIOS application")
|
| 406 | 406 | baseaddr = appheader[2]
|
| 407 | 407 | threadnameptr = appheader[8]
|
| 408 | 408 | nameptr = threadnameptr - baseaddr
|
| — | — | @@ -412,7 +412,7 @@ |
| 413 | 413 | if ord(char) == 0:
|
| 414 | 414 | break
|
| 415 | 415 | except TypeError:
|
| 416 | | - raise ArgumentError("The specified file is not an emBIOS application")
|
| | 416 | + raise ArgumentError("The specified app is not an emBIOS application")
|
| 417 | 417 | name += char
|
| 418 | 418 | nameptr += 1
|
| 419 | 419 | usermem = self.getusermemrange()
|