def fetchcpi(self): opt_config = DEVICE[self.type]['config']['sensor']['options']['cpi'] success, val = fetch_config(self.dev, 'sensor', 'cpi', opt_config) if success: return val else: print("Fetch CPI failed") return False
def fetchcpi(self): config_name = 'cpi' module_config = DEVICE[self.type]['config']['sensor'] options = module_config['options'] module_id = module_config['id'] recipient = self.pid dev = self.dev success, val = fetch_config(dev, recipient, config_name, options, module_id) if success: return val else: print("Fetch CPI failed") return False
def perform_config(dev, args): module_name = args.module option_name = args.option module_config = DEVICE[args.device_type]['config'][module_name] option_config = module_config['options'][option_name] value_type = option_config.type if value_type is not None and args.value is None: success, val = fetch_config(dev, module_name, option_name, option_config) if success: print('Fetched {}/{}: {}'.format(module_name, option_name, val)) else: print('Failed to fetch {}/{}'.format(module_name, option_name)) else: if value_type is None: value = None else: try: value = value_type(args.value) except ValueError: print('Invalid type for {}/{}. Expected {}'.format( module_name, option_name, value_type)) return success = change_config(dev, module_name, option_name, value, option_config) if success: if value_type is None: print('{}/{} set'.format(module_name, option_name)) else: print('{}/{} set to {}'.format(module_name, option_name, value)) else: print('Failed to set {}/{}'.format(module_name, option_name))