#!/usr/bin/python # -*- coding: utf-8 -*- # \file protocol.py # \brief TODO # \author Florent Guiotte # \version 0.1 # \date 07 sept. 2018 # # TODO details import logging import time from collections import OrderedDict class Protocol: def __init__(self, expe, name=None): self._log = logging.getLogger(name) self._expe = expe self._name = name self._times = OrderedDict() self._pt = time.process_time() def get_hashes(self): self._log.info('Computing hashes') return(self._get_hashes()) def run(self): self._kronos = Kronos() self._run() def get_results(self): self._get_results() def get_process_time(self): return self._times() def _time(self, process): self._times[process] = time.process_time() - self._pt self._pt = time.process_time() def _get_hashes(self): self._log.warning('Protocol did not override _get_hashes()') hashes = OrderedDict() hashes['global'] = 'Protocol did not override _get_hashes()' return hashes def _run(self): self._log.error('Protocol did not override _run()') raise NotImplementedError('Protocol {} did not override _run()'.format(self)) def _get_results(self): self._log.warning('Protocol did not override _get_results()') results = OrderedDict() results['global'] = 'Protocol did not override _get_results()' return results def __str__(self): return('{}'.format(self._name)) class TestError(Exception): pass