winIDEA SDK
test_close_open.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import os
6import isystem.connect as ic
7
8
9def test_closeOpen():
10 connMgr = ic.ConnectionMgr()
11 connConfig = ic.CConnectionConfig().start_existing()
12 connMgr.connect(connConfig)
13
14 wksCtrl = ic.CWorkspaceController(connMgr)
15
16 # NOTE: Make sure you have workspace opened before using getPath(), otherwise use the line
17 # of code below and modify it accordingly
18 # wksCtrl.open('<path_to_.xjrf>')
19
20 try:
21 wksFilePath = ic.CIDEController(connMgr).getPath(ic.CIDEController.WORKSPACE_FILE_NAME)
22 except OSError:
23 raise Exception(f'There is no workspace opened. Please open some workspace before running this sample.')
24
25 print(f"Unconditionally closing current workspace: {wksFilePath}")
26 wksCtrl.closeDiscard()
27
28 print("Reopening original workspace...")
29 wksCtrl.open(wksFilePath)
30
31 print("Closing workspace, without discarding any unsaved changes (no changes were made)...")
32 wksCtrl.close()
33
34 print("Reopening original workspace...")
35 wksCtrl.open(wksFilePath)
36
37
38if __name__ == "__main__":
39 test_closeOpen()