import os
import isystem.connect as ic
def test_closeOpen():
connMgr = ic.ConnectionMgr()
connConfig = ic.CConnectionConfig().start_existing()
connMgr.connect(connConfig)
wksCtrl = ic.CWorkspaceController(connMgr)
try:
wksFilePath = ic.CIDEController(connMgr).getPath(ic.CIDEController.WORKSPACE_FILE_NAME)
except OSError:
raise Exception(f'There is no workspace opened. Please open some workspace before running this sample.')
print(f"Unconditionally closing current workspace: {wksFilePath}")
wksCtrl.closeDiscard()
print("Reopening original workspace...")
wksCtrl.open(wksFilePath)
print("Closing workspace, without discarding any unsaved changes (no changes were made)...")
wksCtrl.close()
print("Reopening original workspace...")
wksCtrl.open(wksFilePath)
if __name__ == "__main__":
test_closeOpen()