Skip to content

Commit

Permalink
Another fix for charset conversion. Fixes issue #72
Browse files Browse the repository at this point in the history
  • Loading branch information
ralequi committed Jun 1, 2023
1 parent 876ac0d commit d6ebff7
Show file tree
Hide file tree
Showing 4 changed files with 450 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pySMART/smartctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,13 @@ def _decode_output(self, raw_output: bytes) -> List[str]:
logger.warning(f"Detected encoding: {encoding}")

# Decode the output
decoded_output = raw_output.decode(encoding).splitlines()
decoded_output = raw_output.decode(encoding)

return decoded_output
if encoding != 'utf-8':
decoded_output = decoded_output.encode(
'ascii', 'ignore').decode('ascii')

return decoded_output.splitlines()

def scan(self) -> List[str]:
"""Queries smartctl with option --scan-open
Expand Down
1 change: 1 addition & 0 deletions tests/dataset/singletests/nvme_9_issue_72/_--scan-open
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dev/sda -d nvme # /dev/sda, NVMe device
62 changes: 62 additions & 0 deletions tests/dataset/singletests/nvme_9_issue_72/_-d_nvme_--all__dev_sda
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
smartctl 7.3 2022-02-28 r5338 [x86_64-w64-mingw32-w10-b19045] (sf-7.3-1)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Number: KINGSTON SA2000M8500G
Serial Number: 50026B72826F6BB1
Firmware Version: S5Z42105
PCI Vendor/Subsystem ID: 0x2646
IEEE OUI Identifier: 0x0026b7
Controller ID: 1
NVMe Version: 1.3
Number of Namespaces: 1
Namespace 1 Size/Capacity: 500�107�862�016 [500 GB]
Namespace 1 Utilization: 41�316�155�392 [41,3 GB]
Namespace 1 Formatted LBA Size: 512
Namespace 1 IEEE EUI-64: 0026b7 2826f6bb15
Local Time is: Thu Jun 01 15:01:58 2023 RTZ
Firmware Updates (0x14): 2 Slots, no Reset required
Optional Admin Commands (0x0017): Security Format Frmw_DL Self_Test
Optional NVM Commands (0x005f): Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat Timestmp
Log Page Attributes (0x0f): S/H_per_NS Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg
Maximum Data Transfer Size: 32 Pages
Warning Comp. Temp. Threshold: 75 Celsius
Critical Comp. Temp. Threshold: 80 Celsius

Supported Power States
St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat
0 + 9.00W - - 0 0 0 0 0 0
1 + 4.60W - - 1 1 1 1 0 0
2 + 3.80W - - 2 2 2 2 0 0
3 - 0.0450W - - 3 3 3 3 2000 2000
4 - 0.0040W - - 4 4 4 4 15000 15000

Supported LBA Sizes (NSID 0x1)
Id Fmt Data Metadt Rel_Perf
0 + 512 0 0

=== START OF SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

SMART/Health Information (NVMe Log 0x02)
Critical Warning: 0x00
Temperature: 38 Celsius
Available Spare: 100%
Available Spare Threshold: 10%
Percentage Used: 1%
Data Units Read: 21�600�976 [11,0 TB]
Data Units Written: 16�184�623 [8,28 TB]
Host Read Commands: 272�980�851
Host Write Commands: 210�904�247
Controller Busy Time: 5�077
Power Cycles: 908
Power On Hours: 3�387
Unsafe Shutdowns: 46
Media and Data Integrity Errors: 0
Error Information Log Entries: 0
Warning Comp. Temperature Time: 0
Critical Comp. Temperature Time: 0

Error Information (NVMe Log 0x01, 16 of 256 entries)
No Errors Logged

Loading

0 comments on commit d6ebff7

Please sign in to comment.