Create a SpectrumError(Exception)

Create an exception in case of an error due to spectrum problem
eg if spectrum request is not correct
if values are not correct.
use it instead of exit

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
This commit is contained in:
EstherLerouzic
2019-09-05 17:00:12 +01:00
parent 42ba3eb98d
commit 2f1ab9cc50
2 changed files with 7 additions and 2 deletions

View File

@@ -23,3 +23,6 @@ class ServiceError(Exception):
class DisjunctionError(ServiceError): class DisjunctionError(ServiceError):
'''Disjunction of user-provided request can not be satisfied''' '''Disjunction of user-provided request can not be satisfied'''
class SpectrumError(Exception):
'''Spectrum errors of the program'''

View File

@@ -17,6 +17,7 @@ from collections import namedtuple
from logging import getLogger from logging import getLogger
from math import ceil from math import ceil
from gnpy.core.elements import Roadm, Transceiver from gnpy.core.elements import Roadm, Transceiver
from gnpy.core.exceptions import SpectrumError
LOGGER = getLogger(__name__) LOGGER = getLogger(__name__)
@@ -43,7 +44,8 @@ class Bitmap:
msg = f'bitmap is not consistant with f_min{f_min} - n :' +\ msg = f'bitmap is not consistant with f_min{f_min} - n :' +\
f'{n_min} and f_max{f_max}- n :{n_max}' f'{n_min} and f_max{f_max}- n :{n_max}'
LOGGER.critical(msg) LOGGER.critical(msg)
exit() raise SpectrumError(msg)
def getn(self, i): def getn(self, i):
""" converts the n (itu grid) into a local index """ converts the n (itu grid) into a local index
""" """
@@ -126,7 +128,7 @@ class OMS:
or isinstance(mvalue, float) or mvalue == 0): or isinstance(mvalue, float) or mvalue == 0):
msg = f'could not assign None values' msg = f'could not assign None values'
LOGGER.critical(msg) LOGGER.critical(msg)
exit() raise SpectrumError(msg)
startn, stopn = mvalue_to_slots(nvalue, mvalue) startn, stopn = mvalue_to_slots(nvalue, mvalue)
# print(f'startn stop n {startn} , {stopn}') # print(f'startn stop n {startn} , {stopn}')
# assumes that guardbands are sufficient to ensure that assigning a center channel # assumes that guardbands are sufficient to ensure that assigning a center channel