Skip to content
Snippets Groups Projects
Commit 0a8f5b09 authored by Karim Ahmed's avatar Karim Ahmed Committed by Thomas Kluyver
Browse files

fix: format warning and fix after testing

parent 0aa29adf
No related branches found
No related tags found
1 merge request!1026Feat[Jungfrau]: Inject CCVs using RESTful API
<<<<<<< HEAD
import binascii
import time
=======
import binascii
import time
import warnings
from datetime import datetime, timezone
>>>>>>> 055e516a (fix: handle CCVAlreadyInject case using a warning)
from hashlib import md5
from pathlib import Path
from shutil import copyfile
from struct import pack, unpack
<<<<<<< HEAD
from typing import List, Optional, Union
=======
>>>>>>> 055e516a (fix: handle CCVAlreadyInject case using a warning)
import h5py
import numpy as np
......@@ -30,7 +19,16 @@ from cal_tools.tools import run_prop_seq_from_path
class CCVAlreadyInjected(UserWarning):
"""Exception when same CCV was already injected."""
"""Exception when same CCV was already injected.
expected response: {
'success': False, 'status_code': 422,
'info': 'Error creating calibration_constant_version',
'app_info': {
'calibration_constant_id': ['has already been taken'],
'physical_detector_unit_id': ['has already been taken'],
'begin_at': ['has already been taken']
}, 'pagination': {}, 'data': {}}
"""
pass
CONDITION_NAME_MAX_LENGTH = 60
......@@ -44,6 +42,14 @@ class CCVAlreadyInjectedError(InjectAPIError):
...
def custom_warning_formatter(
message, category, filename, lineno, file=None, line=None):
"""Custom warning format to avoid display filename and lineno."""
return f"{category.__name__}: {message}\n"
# Apply the custom warning formatter
warnings.formatwarning = custom_warning_formatter
def write_ccv(
const_path,
pdu_name, pdu_uuid, detector_type,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment