1 from .command import OnoffCommand
3 def sispmctl_device(sock, device=None):
4 """Create an OnoffCommand that controls the specified socket on a sispmctl
8 @param sock: the socket number of the sispmctl controlled device
9 @type device: None or int or str
10 @param device: optional identification of the device. If this is a number,
11 it is passed via -d. If it is a string, it is used as a serial and
15 if isinstance(device, int):
16 cmd.extend(["-d", "%d" % device])
17 elif isinstance(device, str):
18 cmd.extend(["-D", device])
19 elif device is not None:
20 raise TypeError("passed device must be int, str or None")
22 return OnoffCommand(cmd + ["-o", sock], cmd + ["-f", sock])