a | b/trunk/cforge/cforge/Package/CFORGE/Scripts/import.py | ||
---|---|---|---|
1 | import sys, os |
||
2 | |||
3 | |||
4 | # this script helps to import a given project or library into codesys forge |
||
5 | # it can be called via cforge, but also directly from inside codesys (for now this is experimental!) |
||
6 | |||
7 | |||
8 | def cforge_usage(): |
||
9 | help = [ |
||
10 | ["<path to CODESYS project>", "---"] |
||
11 | ] |
||
12 | |||
13 | return help |
||
14 | |||
15 | bRunningFromCDS = False |
||
16 | |||
17 | |||
18 | try: |
||
19 | p = projects.primary |
||
20 | bRunningFromCDS = True |
||
21 | print("running from cds") |
||
22 | except: |
||
23 | print("not running from cds") |
||
24 | pass |
||
25 | |||
26 | # do the xml export |
||
27 | workingdir = os.path.dirname(sys.argv[0]) |
||
28 | print(workingdir) |
||
29 | sys.path.append(workingdir) |
||
30 | import cds_script |
||
31 | |||
32 | if bRunningFromCDS: |
||
33 | |||
34 | from plcopenxml_export import export |
||
35 | export(scriptargs) |
||
36 | |||
37 | else: # running from cforge |
||
38 | scriptname = os.path.join(workingdir, "plcopenxml_export.py") |
||
39 | scriptargs = sys.argv[1] |
||
40 | |||
41 | cds_script.RunCodesysWithScript(scriptname, scriptargs) |
||
42 | |||
43 | |||
44 | # do the commit |
||
45 | print("commit") |
||
46 | tsvn_workdir="C:\\Program Files\\TortoiseSVN\\bin\\" |
||
47 | bCDSSvn = False |
||
48 | try: |
||
49 | dir(svn) |
||
50 | bCDSSvn = True |
||
51 | except: |
||
52 | print("CODESYS SVN not installed!") |
||
53 | exit() |
||
54 | |||
55 | elif os.path.exists(tsvn_workdir): |
||
56 | print("using Tortoise svn") |
||
57 | filename = scriptargs |
||
58 | |||
59 | e = cds_script.RunProcess(tsvn_workdir,"SubWCRev.exe", filename) |
||
60 | if e == 10: # is not a working copy: |
||
61 | cds_script.RunProcess(tsvn_workdir,"TortoiseProc.exe", '/command:import "/path:' + filename + '"') |
||
62 | else: |
||
63 | cds_script.RunProcess(tsvn_workdir,"TortoiseProc.exe", '/command:commit "/path:' + filename + '"') |
||
64 | |||
65 | |||
66 | |||
67 | else: |
||
68 | print("SVN not installed at all") |