def get_environment(self):
environment = junos_views.junos_enviroment_table(self.device)<EOL>routing_engine = junos_views.junos_routing_engine_table(self.device)<EOL>temperature_thresholds = junos_views.junos_temperature_thresholds(self.device)<EOL>power_supplies = junos_views.junos_pem_table(self.device)<EOL>environment.get()<EOL>routing_engine.get()<EOL>temperature_thresholds.get()<EOL>environment_data = {}<EOL>current_class = None<EOL>for sensor_object, object_data in environment.items():<EOL><INDENT>structured_object_data = {k: v for k, v in object_data}<EOL>if structured_object_data['<STR_LIT:class>']:<EOL><INDENT>current_class = structured_object_data['<STR_LIT:class>']<EOL><DEDENT>else:<EOL><INDENT>structured_object_data['<STR_LIT:class>'] = current_class<EOL><DEDENT>if structured_object_data['<STR_LIT:class>'] == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object] = {}<EOL><DEDENT>except KeyError:<EOL><INDENT>environment_data['<STR_LIT>'] = {}<EOL>environment_data['<STR_LIT>'][sensor_object] = {}<EOL><DEDENT>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT>'] = -<NUM_LIT:1.0><EOL>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT>'] = -<NUM_LIT:1.0><EOL><DEDENT>if structured_object_data['<STR_LIT:class>'] == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object] = {}<EOL><DEDENT>except KeyError:<EOL><INDENT>environment_data['<STR_LIT>'] = {}<EOL>environment_data['<STR_LIT>'][sensor_object] = {}<EOL><DEDENT><DEDENT>status = structured_object_data['<STR_LIT:status>']<EOL>env_class = structured_object_data['<STR_LIT:class>']<EOL>if (status == '<STR_LIT:OK>' and env_class == '<STR_LIT>'):<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT:status>'] = True<EOL><DEDENT>elif (status != '<STR_LIT:OK>' and env_class == '<STR_LIT>'):<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT:status>'] = False<EOL><DEDENT>elif (status == '<STR_LIT:OK>' and env_class == '<STR_LIT>'):<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT:status>'] = True<EOL><DEDENT>elif (status != '<STR_LIT:OK>' and env_class == '<STR_LIT>'):<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT:status>'] = False<EOL><DEDENT>for temperature_object, temperature_data in temperature_thresholds.items():<EOL><INDENT>structured_temperature_data = {k: v for k, v in temperature_data}<EOL>if structured_object_data['<STR_LIT:class>'] == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object] = {}<EOL><DEDENT>except KeyError:<EOL><INDENT>environment_data['<STR_LIT>'] = {}<EOL>environment_data['<STR_LIT>'][sensor_object] = {}<EOL><DEDENT>if structured_object_data['<STR_LIT>']:<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT>'] =float(structured_object_data['<STR_LIT>'])<EOL><DEDENT>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT>'] = False<EOL>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT>'] = False<EOL>temp = structured_object_data['<STR_LIT>']<EOL>if structured_temperature_data['<STR_LIT>'] <= temp:<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT>'] = True<EOL>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT>'] = True<EOL><DEDENT>elif structured_temperature_data['<STR_LIT>'] <= temp:<EOL><INDENT>environment_data['<STR_LIT>'][sensor_object]['<STR_LIT>'] = True<EOL><DEDENT><DEDENT><DEDENT><DEDENT>pem_table = dict()<EOL>try:<EOL><INDENT>power_supplies.get()<EOL><DEDENT>except RpcError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>for pem in power_supplies.items():<EOL><INDENT>pem_name = pem[<NUM_LIT:0>].replace("<STR_LIT>", "<STR_LIT>")<EOL>pem_table[pem_name] = dict(pem[<NUM_LIT:1>])<EOL>environment_data['<STR_LIT>'][pem_name]['<STR_LIT>'] = pem_table[pem_name]['<STR_LIT>']<EOL>environment_data['<STR_LIT>'][pem_name]['<STR_LIT>'] = pem_table[pem_name]['<STR_LIT>']<EOL><DEDENT><DEDENT>for routing_engine_object, routing_engine_data in routing_engine.items():<EOL><INDENT>structured_routing_engine_data = {k: v for k, v in routing_engine_data}<EOL>try:<EOL><INDENT>environment_data['<STR_LIT>'][routing_engine_object] = {}<EOL>environment_data['<STR_LIT>'] = {}<EOL><DEDENT>except KeyError:<EOL><INDENT>environment_data['<STR_LIT>'] = {}<EOL>environment_data['<STR_LIT>'][routing_engine_object] = {}<EOL>environment_data['<STR_LIT>'] = {}<EOL><DEDENT>environment_data['<STR_LIT>'][routing_engine_object]['<STR_LIT>'] =<NUM_LIT> - structured_routing_engine_data['<STR_LIT>']<EOL>try:<EOL><INDENT>environment_data['<STR_LIT>']['<STR_LIT>'] =int(structured_routing_engine_data['<STR_LIT>'])<EOL><DEDENT>except ValueError:<EOL><INDENT>environment_data['<STR_LIT>']['<STR_LIT>'] =int(<EOL>'<STR_LIT>'.join(<EOL>i for i in structured_routing_engine_data['<STR_LIT>']<EOL>if i.isdigit()<EOL>)<EOL>)<EOL><DEDENT>environment_data['<STR_LIT>']['<STR_LIT>'] =int(round(environment_data['<STR_LIT>']['<STR_LIT>'] / <NUM_LIT> *<EOL>structured_routing_engine_data['<STR_LIT>']))<EOL><DEDENT>return environment_data<EOL>
Return environment details.