This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/parser/snapshot.py

50 lines
1.5 KiB
Python
Raw Normal View History

2022-03-22 12:17:41 +00:00
from datetime import datetime, timezone
from enum import Enum, unique
2022-03-29 15:09:40 +00:00
from typing import List
2022-03-22 12:17:41 +00:00
2022-03-29 15:09:40 +00:00
from ereuse_workbench.computer import Component, Computer, DataStorage
2022-03-22 12:17:41 +00:00
from ereuse_workbench.utils import Dumpeable
@unique
class SnapshotSoftware(Enum):
"""The algorithm_software used to perform the Snapshot."""
2022-03-29 15:09:40 +00:00
2022-03-22 12:17:41 +00:00
Workbench = 'Workbench'
AndroidApp = 'AndroidApp'
Web = 'Web'
DesktopApp = 'DesktopApp'
class Snapshot(Dumpeable):
"""
Generates the Snapshot report for Devicehub by obtaining the
data from the computer, performing benchmarks and tests...
After instantiating the class, run :meth:`.computer` before any
other method.
"""
def __init__(self, uuid, software, version, lshw, hwinfo):
self.type = 'Snapshot'
self.uuid = uuid
self.software = software
self.version = version
self.lshw = lshw
self.hwinfo = hwinfo
self.endTime = datetime.now(timezone.utc)
self.closed = False
self.elapsed = None
self.device = None # type: Computer
self.components = None # type: List[Component]
self._storages = None
def computer(self):
"""Retrieves information about the computer and components."""
self.device, self.components = Computer.run(self.lshw, self.hwinfo)
self._storages = tuple(c for c in self.components if isinstance(c, DataStorage))
def close(self):
2022-03-29 15:09:40 +00:00
"""Closes the Snapshot"""
2022-03-22 12:17:41 +00:00
self.closed = True