winIDEA SDK
Loading...
Searching...
No Matches
test_find_existing_instance.py
# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
#
# (c) TASKING Germany GmbH, 2023
import isystem.connect as ic
def test_findExistingInstance():
print("Finding existing instance by ID...")
cfg = ic.CConnectionConfig()
cfg.instanceId("findExistingInstanceExample")
cfg.start_if_required()
connMgr = ic.ConnectionMgr()
connMgr.connect(cfg)
cfg2 = ic.CConnectionConfig()
cfg2.start_existing()
cfg2.instanceId("findExistingInstanceExample")
connMgr.disconnect_keep()
connMgr.connect(cfg2)
port = cfg2.getTCPPort()
if port > 0:
print(f"Instance found, port: {port}")
else:
print(f"Instance with ID 'findExistingInstanceExample' not found")
# alternatively, user can find instance by specifying workspace file path
# cfg.workspace("C:/Desktop/myWorkspace/Sample.xjrf")
connMgr.disconnect_close(False)
if __name__ == "__main__":
test_findExistingInstance()