a | b/trunk/cforge/cforge/Package/CFORGE/Scripts/action.svn.update.py | ||
---|---|---|---|
1 | # Example Batch: |
||
2 | # set WD=%~d0%~p0 |
||
3 | # set USER=<username> |
||
4 | # set PASS=<password> |
||
5 | # set URL=https://forge.codesys.com/svn/drv,gpio-mod,code/trunk/GPIOMods |
||
6 | # "C:\Program Files (x86)\3S CODESYS-V3.5.12.0\CODESYS\Common\CODESYS.exe" --profile="CODESYS V3.5 SP12" --runscript="%WD%\action.svn.checkout.py" --scriptargs="%URL% %USER% %PASS% %WD%" --noUI |
||
7 | |||
8 | import sys |
||
9 | import os.path |
||
10 | import pysvn |
||
11 | |||
12 | if len(sys.argv) <= 1: |
||
13 | print("usage: <user> <pass> <working dir>") |
||
14 | sys.exit() |
||
15 | |||
16 | if len(sys.argv) > 2: |
||
17 | username = sys.argv[1] |
||
18 | password = sys.argv[2] |
||
19 | |||
20 | if len(sys.argv) > 3: |
||
21 | path = sys.argv[3] |
||
22 | |||
23 | def set_username(req): |
||
24 | req.username = username |
||
25 | req.password = password |
||
26 | req.save = True # Optional |
||
27 | |||
28 | svn.auth_username_password += set_username |
||
29 | # checkout plain SVN files |
||
30 | pysvn.svn_update_non_codesys(username, password, path) |
||
31 | |||
32 | # iterate over all projects and libraries |
||
33 | for root, dirs, files in os.walk(path): |
||
34 | for file in files: |
||
35 | if file.endswith(".project") or file.endswith(".library"): |
||
36 | filepath = os.path.join(root, file) |
||
37 | proj = projects.open(filepath) |
||
38 | proj.svn.update() |
||
39 | proj.save() |
||
40 | proj.close() |
||
41 | |||
42 | system.exit() |
||
43 | |||
44 |