mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-02 11:07:57 +00:00
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:
@@ -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'''
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user