Skip to content

Commit 7bceef2

Browse files
committed
[OMCSessionZMQ] rename some variables; define as public
1 parent 1545ebc commit 7bceef2

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

OMPython/OMCSession.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -280,31 +280,31 @@ def __init__(self,
280280
omc_process = OMCProcessLocal(omhome=omhome, timeout=timeout)
281281
elif not isinstance(omc_process, OMCProcess):
282282
raise OMCSessionException("Invalid definition of the OMC process!")
283-
self._omc_process = omc_process
284-
285-
# variables to store compiled re expressions use in self.sendExpression()
286-
self._re_log_entries = None
287-
self._re_log_raw = None
283+
self.omc_process = omc_process
288284

289285
# Create the ZeroMQ socket and connect to OMC server
290286
context = zmq.Context.instance()
291287
omc = context.socket(zmq.REQ)
292288
omc.setsockopt(zmq.LINGER, 0) # Dismisses pending messages if closed
293289
omc.setsockopt(zmq.IMMEDIATE, True) # Queue messages only to completed connections
294-
omc.connect(self._omc_process.get_port())
290+
omc.connect(self.omc_process.get_port())
295291

296-
self._omc = omc
292+
self.omc_zmq = omc
293+
294+
# variables to store compiled re expressions use in self.sendExpression()
295+
self._re_log_entries = None
296+
self._re_log_raw = None
297297

298298
def __del__(self):
299-
if self._omc:
299+
if self.omc_zmq:
300300
try:
301301
self.sendExpression("quit()")
302302
except OMCSessionException:
303303
pass
304304

305-
del self._omc
305+
del self.omc_zmq
306306

307-
self._omc = None
307+
self.omc_zmq = None
308308

309309
def execute(self, command):
310310
warnings.warn("This function is depreciated and will be removed in future versions; "
@@ -313,19 +313,19 @@ def execute(self, command):
313313
return self.sendExpression(command, parsed=False)
314314

315315
def sendExpression(self, command, parsed=True):
316-
p = self._omc_process.poll() # check if process is running
316+
p = self.omc_process.poll() # check if process is running
317317
if p is not None:
318318
raise OMCSessionException("Process Exited, No connection with OMC. Create a new instance of OMCSessionZMQ!")
319319

320-
if self._omc is None:
320+
if self.omc_zmq is None:
321321
raise OMCSessionException("No OMC running. Create a new instance of OMCSessionZMQ!")
322322

323323
logger.debug("sendExpression(%r, parsed=%r)", command, parsed)
324324

325325
attempts = 0
326326
while True:
327327
try:
328-
self._omc.send_string(str(command), flags=zmq.NOBLOCK)
328+
self.omc_zmq.send_string(str(command), flags=zmq.NOBLOCK)
329329
break
330330
except zmq.error.Again:
331331
pass
@@ -337,11 +337,11 @@ def sendExpression(self, command, parsed=True):
337337
raise OMCSessionException(f"No connection with OMC (timeout={self._timeout}). Log-file says: \n{log}")
338338
time.sleep(self._timeout / 50.0)
339339
if command == "quit()":
340-
self._omc.close()
341-
self._omc = None
340+
self.omc_zmq.close()
341+
self.omc_zmq = None
342342
return None
343343
else:
344-
result = self._omc.recv_string()
344+
result = self.omc_zmq.recv_string()
345345

346346
if command == "getErrorString()":
347347
# no error handling if 'getErrorString()' is called
@@ -353,8 +353,8 @@ def sendExpression(self, command, parsed=True):
353353
parsed = False
354354
else:
355355
# allways check for error
356-
self._omc.send_string('getMessagesStringInternal()', flags=zmq.NOBLOCK)
357-
error_raw = self._omc.recv_string()
356+
self.omc_zmq.send_string('getMessagesStringInternal()', flags=zmq.NOBLOCK)
357+
error_raw = self.omc_zmq.recv_string()
358358
# run error handling only if there is something to check
359359
if error_raw != "{}\n":
360360
if not self._re_log_entries:

0 commit comments

Comments
 (0)