winIDEA SDK
test_read_write.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import os
6import tempfile
7
8import isystem.connect as ic
9
10
11winidea_id = ''
12
13
14def test_readWrite():
15 connMgr = ic.ConnectionMgr()
16 # normally, here you would do connection to a remote winIDEA
17 # for this test, local winIDEA is used
18 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
19
20 rfCtrl = ic.CRemoteFileController(connMgr)
21
22 with tempfile.TemporaryDirectory() as tmpDirPath:
23 filePath = os.path.join(tmpDirPath, "localFile.txt")
24 rfCtrl = ic.CRemoteFileController(connMgr)
25
26 rfCtrl.readFromRemote("src/main.cpp", filePath)
27 print(f"Remote file read into: {filePath}")
28
29 print(f"Writing local file back to remote 'src/main.cpp'...")
30 rfCtrl.writeToRemote(filePath, "src/main_write_back.cpp")
31
32
33if __name__ == "__main__":
34 test_readWrite()