Commit 2a8446aa authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Common - Tools - Context Queries:

- Fixed find_optical_band method
parent cf14c841
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -13,12 +13,15 @@
# limitations under the License.


from common.method_wrappers.ServiceExceptions import InvalidArgumentsException
from context.client.ContextClient import ContextClient
import logging
from typing import Optional, Union
from uuid import UUID, uuid4, uuid5
from common.method_wrappers.ServiceExceptions import InvalidArgumentsException
from common.proto.context_pb2 import OpticalBand, OpticalBandId, Empty
from context.client.ContextClient import ContextClient

LOGGER = logging.getLogger(__name__)

# Generate a UUIDv5-like from the SHA-1 of "TFS" and no namespace to be used as the NAMESPACE for all
# the context UUIDs generated. For efficiency purposes, the UUID is hardcoded; however, it is produced
# using the following code:
@@ -98,8 +101,7 @@ def ob_get_uuid(



def find_optical_band (ob_index)->OpticalBand:

def find_optical_band(ob_index) -> Optional[OpticalBand]:
    op_uuid = ob_get_uuid(ob_index)
    op_id = OpticalBandId()
    op_id.opticalband_uuid.uuid = op_uuid
@@ -107,5 +109,7 @@ def find_optical_band (ob_index)->OpticalBand:
        ctxt = ContextClient()
        target_ob = ctxt.SelectOpticalBand(op_id)
        return target_ob
    except Exception as e : 
            logging.debug(f"error in finding optical band {e}")
    except Exception:
        MSG = 'Unable to find OpticalBand({:s}/{:s}) in Context'
        LOGGER.exception(MSG.format(str(ob_index), str(op_uuid)))
        return None