diff --git a/qnapstats/qnap_stats.py b/qnapstats/qnap_stats.py index 1758738..4987182 100644 --- a/qnapstats/qnap_stats.py +++ b/qnapstats/qnap_stats.py @@ -229,8 +229,8 @@ def get_system_stats(self): "name": root["server_name"], "model": resp["model"]["displayModelName"], "serial_number": root["serial_number"], - "temp_c": int(root["sys_tempc"]), - "temp_f": int(root["sys_tempf"]), + "temp_c": int(root["sys_tempc"]) if "sys_tempc" in root else None, + "temp_f": int(root["sys_tempf"]) if "sys_tempf" in root else None, "timezone": root["timezone"], }, "firmware": { diff --git a/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/login.xml b/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/login.xml new file mode 100644 index 0000000..442260e --- /dev/null +++ b/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/login.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + <![CDATA[]]> + + + + + diff --git a/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/login_with_get.xml b/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/login_with_get.xml new file mode 100644 index 0000000..4761d49 --- /dev/null +++ b/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/login_with_get.xml @@ -0,0 +1,4 @@ + + + +<![CDATA[]]> \ No newline at end of file diff --git a/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/systemstats.json b/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/systemstats.json new file mode 100644 index 0000000..687ea74 --- /dev/null +++ b/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/systemstats.json @@ -0,0 +1 @@ +{"cpu": {"model": null, "temp_c": null, "temp_f": null, "usage_percent": 48.5}, "dns": ["192.168.1.1"], "firmware": {"build": "20170121", "build_time": "21-01-2017", "patch": "0", "version": "4.2.3"}, "memory": {"free": 60.8, "total": 249.6}, "nics": {"eth0": {"err_packets": 0, "ip": "192.168.1.101", "link_status": "Up", "mac": "00:08:9B:C1:80:6A", "mask": "255.255.255.0", "max_speed": 1000, "rx_packets": 193439491, "tx_packets": 123234929, "usage": "DHCP"}, "eth1": {"err_packets": 0, "ip": "0.0.0.0", "link_status": "Down", "mac": "00:08:9B:C1:80:6B", "mask": "0.0.0.0", "max_speed": 1000, "rx_packets": 0, "tx_packets": 0, "usage": "DHCP"}}, "sysfans": {}, "system": {"model": "TS-253 Pro", "name": "hornbill", "serial_number": "MYSERIAL", "temp_c": null, "temp_f": null, "timezone": "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"}, "uptime": {"days": 13, "hours": 17, "minutes": 47, "seconds": 48}} \ No newline at end of file diff --git a/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/systemstats.xml b/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/systemstats.xml new file mode 100644 index 0000000..27f6fbd --- /dev/null +++ b/tests/responses/TS-X53-4.5.4-faulty-sys-sensor/systemstats.xml @@ -0,0 +1,31 @@ + +0 + + + +193439491 +123234929 +0 +1 +1000 +192.168.1.101 +255.255.255.0 +00:08:9B:C1:80:6A +DHCP +0 +0 +0 +0 +1000 +0.0.0.0 +0.0.0.0 +00:08:9B:C1:80:6B +DHCP + +0 +MYSERIAL + + + + \ No newline at end of file