def get_environment(self):
environment = junos_views.junos_environment_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][<EOL>"<STR_LIT>"<EOL>] = float(structured_object_data["<STR_LIT>"])<EOL><DEDENT>environment_data["<STR_LIT>"][sensor_object]["<STR_LIT>"] = False<EOL>environment_data["<STR_LIT>"][sensor_object][<EOL>"<STR_LIT>"<EOL>] = False<EOL>temp = structured_object_data["<STR_LIT>"]<EOL>if temp is not None:<EOL><INDENT>if structured_temperature_data["<STR_LIT>"] <= temp:<EOL><INDENT>environment_data["<STR_LIT>"][sensor_object][<EOL>"<STR_LIT>"<EOL>] = True<EOL>environment_data["<STR_LIT>"][sensor_object][<EOL>"<STR_LIT>"<EOL>] = True<EOL><DEDENT>elif structured_temperature_data["<STR_LIT>"] <= temp:<EOL><INDENT>environment_data["<STR_LIT>"][sensor_object][<EOL>"<STR_LIT>"<EOL>] = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>environment_data["<STR_LIT>"][sensor_object][<EOL>"<STR_LIT>"<EOL>] = <NUM_LIT:0.0><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>if "<STR_LIT>" not in environment_data.keys():<EOL><INDENT>environment_data["<STR_LIT>"] = {}<EOL>for pem in power_supplies.items():<EOL><INDENT>pem_name = pem[<NUM_LIT:0>].replace("<STR_LIT>", "<STR_LIT>")<EOL>environment_data["<STR_LIT>"][pem_name] = {}<EOL>environment_data["<STR_LIT>"][pem_name]["<STR_LIT>"] = -<NUM_LIT:1.0><EOL>environment_data["<STR_LIT>"][pem_name]["<STR_LIT>"] = -<NUM_LIT:1.0><EOL>environment_data["<STR_LIT>"][pem_name]["<STR_LIT:status>"] = False<EOL><DEDENT><DEDENT>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>if pem_table[pem_name]["<STR_LIT>"] is not None:<EOL><INDENT>environment_data["<STR_LIT>"][pem_name]["<STR_LIT>"] = pem_table[<EOL>pem_name<EOL>]["<STR_LIT>"]<EOL><DEDENT>if pem_table[pem_name]["<STR_LIT>"] is not None:<EOL><INDENT>environment_data["<STR_LIT>"][pem_name]["<STR_LIT>"] = pem_table[pem_name][<EOL>"<STR_LIT>"<EOL>]<EOL><DEDENT>environment_data["<STR_LIT>"][pem_name]["<STR_LIT:status>"] = pem_table[pem_name][<EOL>"<STR_LIT:status>"<EOL>]<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>"] = (<EOL><NUM_LIT> - structured_routing_engine_data["<STR_LIT>"]<EOL>)<EOL>try:<EOL><INDENT>environment_data["<STR_LIT>"]["<STR_LIT>"] = int(<EOL>structured_routing_engine_data["<STR_LIT>"]<EOL>)<EOL><DEDENT>except ValueError:<EOL><INDENT>environment_data["<STR_LIT>"]["<STR_LIT>"] = int(<EOL>"<STR_LIT>".join(<EOL>i<EOL>for i in structured_routing_engine_data["<STR_LIT>"]<EOL>if i.isdigit()<EOL>)<EOL>)<EOL><DEDENT>environment_data["<STR_LIT>"]["<STR_LIT>"] = int(<EOL>round(<EOL>environment_data["<STR_LIT>"]["<STR_LIT>"]<EOL>/ <NUM_LIT><EOL>* structured_routing_engine_data["<STR_LIT>"]<EOL>)<EOL>)<EOL><DEDENT>return environment_data<EOL>
Return environment details.