winIDEA SDK
test_save.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import os
6
7import isystem.connect as ic
8
9
10winidea_id = ''
11
12
13def test_save():
14 connMgr = ic.ConnectionMgr()
15 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
16
17 docCtrl = ic.CDocumentController(connMgr, 'CORE0/startup.c', "r")
18
19 print("Saving selected document ('CORE0/startup.c')...")
20 docCtrl.save()
21
22 print("Saving selected document ('CORE0/startup.c') copy: 'CORE0/startup_copy.c'...")
23 try:
24 docCtrl.saveCopy('CORE0/startup_copy.c')
25 except Warning as wrn:
26 print("File existed and was overwritten!")
27
28 print("Saving selected document ('CORE0/startup.c') with a "
29 "new name: 'CORE0/startup_saveAs.c'...")
30 try:
31 docCtrl.saveAs('CORE0/startup_saveAs.c')
32 except AttributeError as exc:
33 print("Could not save: " + str(exc))
34
35 # alternatively, save the document with GUI prompt:
36 # docCtrl.saveAsPrompt()
37
38
39if __name__ == "__main__":
40 test_save()