Skip to content

Commit

Permalink
Use context manager to open and close the connection
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroEzq committed Aug 29, 2024
1 parent 431c35c commit 4d1497f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions gui/CAEN-N1471H/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,16 +550,14 @@ def update_alarm_indicators(self):
args = parser.parse_args()

if not args.test:
caen = hvps.Caen(port=args.port)

print("port:", caen.port)
print("baudrate:", caen.baudrate)

m = caen.module(0)
with hvps.Caen(port=args.port) as caen:
print("port:", caen.port)
print("baudrate:", caen.baudrate)
m = caen.module(0)
CaenHVPSGUI(module=m, channel_names=CHANNEL_NAMES)

else:
from caen_simulator import * # noqa: F403

m = ModuleSimulator(4) # noqa: F405

CaenHVPSGUI(module=m, channel_names=CHANNEL_NAMES)
CaenHVPSGUI(module=m, channel_names=CHANNEL_NAMES)

0 comments on commit 4d1497f

Please sign in to comment.