class ICPi7000(object): is_remote = False def __init__(self, remote=False, *args, **kwargs): if remote: self.is_remote= True self.remote = RemoteCommand(*args, **kwargs) else: self.icp = ICP(*args, **kwargs) def status(self, module=1): if self.is_remote: return self.remote("status", module=module) return self.icp.status(module=module) def on(self, module=1, channel=0): if self.is_remote: return self.remote("on", module=module, channel=channel) self.icp.on(module=module, channel=channel) status = self.status(module=module) try: return bool(status[module]) except: raise RuntimeError(unicode(_('Device is not responding.'))) def off(self, module=1, channel=0): if self.is_remote: return self.remote("off", module=module, channel=channel) self.icp.off(module=module, channel=channel) status = self.status(module=module) try: return bool(not status[module]) except: raise RuntimeError(unicode(_('Device is not responding.')))
def __init__(self, remote=False, *args, **kwargs): if remote: self.is_remote= True self.remote = RemoteCommand(*args, **kwargs) else: self.icp = ICP(*args, **kwargs)