Skip to content

Commit d6ebff7

Browse files
committed
Another fix for charset conversion. Fixes issue #72
1 parent 876ac0d commit d6ebff7

File tree

4 files changed

+450
-2
lines changed

4 files changed

+450
-2
lines changed

pySMART/smartctl.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,13 @@ def _decode_output(self, raw_output: bytes) -> List[str]:
174174
logger.warning(f"Detected encoding: {encoding}")
175175

176176
# Decode the output
177-
decoded_output = raw_output.decode(encoding).splitlines()
177+
decoded_output = raw_output.decode(encoding)
178178

179-
return decoded_output
179+
if encoding != 'utf-8':
180+
decoded_output = decoded_output.encode(
181+
'ascii', 'ignore').decode('ascii')
182+
183+
return decoded_output.splitlines()
180184

181185
def scan(self) -> List[str]:
182186
"""Queries smartctl with option --scan-open
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dev/sda -d nvme # /dev/sda, NVMe device
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
smartctl 7.3 2022-02-28 r5338 [x86_64-w64-mingw32-w10-b19045] (sf-7.3-1)
2+
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org
3+
4+
=== START OF INFORMATION SECTION ===
5+
Model Number: KINGSTON SA2000M8500G
6+
Serial Number: 50026B72826F6BB1
7+
Firmware Version: S5Z42105
8+
PCI Vendor/Subsystem ID: 0x2646
9+
IEEE OUI Identifier: 0x0026b7
10+
Controller ID: 1
11+
NVMe Version: 1.3
12+
Number of Namespaces: 1
13+
Namespace 1 Size/Capacity: 500�107�862�016 [500 GB]
14+
Namespace 1 Utilization: 41�316�155�392 [41,3 GB]
15+
Namespace 1 Formatted LBA Size: 512
16+
Namespace 1 IEEE EUI-64: 0026b7 2826f6bb15
17+
Local Time is: Thu Jun 01 15:01:58 2023 RTZ
18+
Firmware Updates (0x14): 2 Slots, no Reset required
19+
Optional Admin Commands (0x0017): Security Format Frmw_DL Self_Test
20+
Optional NVM Commands (0x005f): Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat Timestmp
21+
Log Page Attributes (0x0f): S/H_per_NS Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg
22+
Maximum Data Transfer Size: 32 Pages
23+
Warning Comp. Temp. Threshold: 75 Celsius
24+
Critical Comp. Temp. Threshold: 80 Celsius
25+
26+
Supported Power States
27+
St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat
28+
0 + 9.00W - - 0 0 0 0 0 0
29+
1 + 4.60W - - 1 1 1 1 0 0
30+
2 + 3.80W - - 2 2 2 2 0 0
31+
3 - 0.0450W - - 3 3 3 3 2000 2000
32+
4 - 0.0040W - - 4 4 4 4 15000 15000
33+
34+
Supported LBA Sizes (NSID 0x1)
35+
Id Fmt Data Metadt Rel_Perf
36+
0 + 512 0 0
37+
38+
=== START OF SMART DATA SECTION ===
39+
SMART overall-health self-assessment test result: PASSED
40+
41+
SMART/Health Information (NVMe Log 0x02)
42+
Critical Warning: 0x00
43+
Temperature: 38 Celsius
44+
Available Spare: 100%
45+
Available Spare Threshold: 10%
46+
Percentage Used: 1%
47+
Data Units Read: 21�600�976 [11,0 TB]
48+
Data Units Written: 16�184�623 [8,28 TB]
49+
Host Read Commands: 272�980�851
50+
Host Write Commands: 210�904�247
51+
Controller Busy Time: 5�077
52+
Power Cycles: 908
53+
Power On Hours: 3�387
54+
Unsafe Shutdowns: 46
55+
Media and Data Integrity Errors: 0
56+
Error Information Log Entries: 0
57+
Warning Comp. Temperature Time: 0
58+
Critical Comp. Temperature Time: 0
59+
60+
Error Information (NVMe Log 0x01, 16 of 256 entries)
61+
No Errors Logged
62+

0 commit comments

Comments
 (0)