Skip to content

Commit

Permalink
Merge branch 'develop' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ralequi authored Apr 19, 2024
2 parents 9cce6e2 + a981bff commit 62d8752
Show file tree
Hide file tree
Showing 34 changed files with 1,538 additions and 213 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Version 1.3.1
- Added support for test polling_minutes. Requested in [#77](https://github.com/truenas/py-SMART/issues/77) and [#78](https://github.com/truenas/py-SMART/pull/78). Thanks @Gigahawk
- Minnor typo fixed in NvmeAttributes (issue [#81](https://github.com/truenas/py-SMART/issues/81)). Thanks @petersulyok
- Minnor fix for JBOD devices (MR [#85](https://github.com/truenas/py-SMART/pull/85)). Thanks @jackeichen
- Fixed __getstate__ method in Device class. (issue [#86](https://github.com/truenas/py-SMART/issues/86)). Thanks @f18m
- **Breaking changes**
- **smartctl.all**:
- Officially removed support for python 3.7.
Expand Down
31 changes: 14 additions & 17 deletions pySMART/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,36 +481,33 @@ def __repr__(self):
self.serial
)

def __getstate__(self, all_info=True):
def __getstate__(self, all_info=True) -> Dict:
"""
Allows us to send a pySMART Device object over a serializable
medium which uses json (or the likes of json) payloads
"""
return None

state_dict = {
'attributes': [attr.__getstate__() if attr else None for attr in self.attributes],
'capacity': self._capacity_human,
'diagnostics': self.diagnostics.__getstate__(all_info),
'firmware': self.firmware,
'if_attributes': self.if_attributes.__getstate__() if self.if_attributes else None,
'interface': self._interface if self._interface else 'UNKNOWN INTERFACE',
'is_ssd': self.is_ssd,
'messages': self.messages,
'model': self.model,
'firmware': self.firmware,
'name': self.name,
'path': self.dev_reference,
'rotation_rate': self.rotation_rate,
'serial': self.serial,
'smart_capable': self.smart_capable,
'smart_enabled': self.smart_enabled,
'smart_status': self.assessment,
'messages': self.messages,
'temperature': self.temperature,
'test_capabilities': self.test_capabilities.copy(),
'tests': [t.__getstate__() for t in self.tests] if self.tests else [],
'diagnostics': self.diagnostics.__getstate__(all_info),
'temperature': self.temperature,
'attributes': [attr.__getstate__() if attr else None for attr in self.attributes],
'if_attributes': self.if_attributes.__getstate__(all_info) if self.if_attributes else None,
}
if all_info:
state_dict.update({
'name': self.name,
'path': self.dev_reference,
'serial': self.serial,
'is_ssd': self.is_ssd,
'rotation_rate': self.rotation_rate,
'capacity': self._capacity_human
})
return state_dict

def __setstate__(self, state):
Expand Down
2 changes: 1 addition & 1 deletion pySMART/interface/ata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def parse(self, data: Iterator[str]) -> None:
self.legacyAttributes[int(tmp['id'])] = Attribute(
int(tmp['id']), tmp['name'], int(tmp['flag'], base=16), tmp['value'], tmp['worst'], tmp['thresh'], tmp['type'], tmp['updated'], tmp['whenfailed'], tmp['raw'])

def __getstate__(self, all_info=True):
def __getstate__(self):
"""
Allows us to send a pySMART diagnostics object over a serializable
medium which uses json (or the likes of json) payloads
Expand Down
15 changes: 5 additions & 10 deletions pySMART/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ def get_object_properties(obj: Any, deep_copy: bool = True, remove_private: bool
if obj is None:
return None

if hasattr(obj, '__getstate__'):
obj_state = obj.__getstate__()
if obj_state is not None:
return obj_state

if not hasattr(obj, '__dict__'):
return obj

Expand All @@ -193,11 +188,11 @@ def get_object_properties(obj: Any, deep_copy: bool = True, remove_private: bool
# Get properties from objects
if (prop_val_type_name in available_types) and (prop_name not in ret):
# Check if prop_val has __getstate__ method, if so, call it
if hasattr(prop_val, '__getstate__'):
prop_val_state = prop_val.__getstate__()
if prop_val_state is not None:
ret[prop_name] = prop_val
continue # Do not do recursion
# if hasattr(prop_val, '__getstate__'):
# prop_val_state = prop_val.__getstate__()
# if prop_val_state is not None:
# ret[prop_name] = prop_val
# continue # Do not do recursion

ret[prop_name] = prop_val

Expand Down
19 changes: 15 additions & 4 deletions tests/dataset/singletests/megaraid_ph_sas_hdd_0/device.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,19 @@
"Load_Cycle_Spec": 600000,
"Non_Medium_Errors": null,
"Power_On_Hours": null,
"Reads_GB": 16772.475,
"Reads_count": 35174429491,
"Reallocated_Sector_Ct": 0,
"Start_Stop_Cycles": 101,
"Start_Stop_Pct_Left": 100,
"Start_Stop_Spec": 50000,
"Uncorrected_Reads": 0,
"Uncorrected_Verifies": 0,
"Uncorrected_Writes": 0,
"Verifies_GB": 3464.82,
"Verifies_count": 7266254192,
"Writes_GB": 574543.134,
"Writes_count": 1204904282554,
"_Reads_GB": 16772.475,
"_Reads_count": null,
"_Uncorrected_Reads": 0,
Expand All @@ -288,7 +297,8 @@
"_Verifies_count": null,
"_Writes_GB": 574543.134,
"_Writes_count": null,
"_block_size": 512
"_block_size": 512,
"block_size": 512
},
"diags": {
"Corrected_Reads": "8",
Expand Down Expand Up @@ -349,11 +359,12 @@
},
"tests": [
{
"asc": "-",
"ascq": "-",
"ASC": "-",
"ASCQ": "-",
"LBA": "-",
"_format": "scsi",
"code": null,
"hours": "302",
"lba": "-",
"nsid": null,
"num": 1,
"remain": null,
Expand Down
Loading

0 comments on commit 62d8752

Please sign in to comment.