a/trunk/cforge/cforge/Package/CFORGE/Scripts/checkout-prj.py | b/trunk/cforge/cforge/Package/CFORGE/Scripts/checkout-prj.py | ||
---|---|---|---|
1 | import sys, os |
1 | import sys, os |
2 | import ui |
||
3 | import pysvn |
2 | import pysvn |
4 | import json |
3 | import json |
5 | from System.Net import WebClient |
4 | |
5 | hasWebClient = True |
||
6 | try: |
||
7 | from System.Net import WebClient
|
||
8 | except: |
||
9 | import requests |
||
10 | hasWebClient = False |
||
11 | |||
12 | hasUI = True |
||
13 | try: |
||
14 | import ui |
||
15 | except: |
||
16 | hasUI = False |
||
6 | 17 | ||
7 | base_url = "https://forge.codesys.com/rest" |
18 | base_url = "https://forge.codesys.com/rest" |
8 | base_svn = "https://forge.codesys.com/svn/" |
19 | base_svn = "https://forge.codesys.com/svn/" |
9 | 20 | ||
10 | # This is a cforge command (script file) |
21 | # This is a cforge command (script file) |
... |
... |
||
21 | ] |
32 | ] |
22 | 33 | ||
23 | return help |
34 | return help |
24 | 35 | ||
25 | def get_json(url): |
36 | def get_json(url): |
26 | web_client = WebClient() |
37 | r = "" |
38 | if hasWebClient: |
||
39 | web_client = WebClient() |
||
27 | r = web_client.DownloadData(url) |
40 | r = web_client.DownloadData(url) |
41 | else: |
||
42 | r = requests.get(url).content |
||
43 | |||
28 | j = json.loads(bytes(r).decode('utf-8')) |
44 | j = json.loads(bytes(r).decode('utf-8')) |
29 | return j |
45 | return j |
30 | 46 | ||
31 | |||
32 | if len(sys.argv) <= 1: |
47 | if len(sys.argv) <= 1: |
33 | print("Oh, there are no arguments. Perhaps you forgot something?") |
48 | print("Oh, there are no arguments. Perhaps you forgot something?") |
34 | sys.exit() |
49 | sys.exit() |
35 | 50 | ||
36 | args = sys.argv[1].split(" ") |
51 | args = sys.argv[1].split(" ") |
... |
... |
||
42 | config = dict() |
57 | config = dict() |
43 | if len(sys.argv)>= 3: |
58 | if len(sys.argv)>= 3: |
44 | config['user'] = sys.argv[2] |
59 | config['user'] = sys.argv[2] |
45 | config['pass'] = sys.argv[3] |
60 | config['pass'] = sys.argv[3] |
46 | config['folder'] = sys.argv[4] |
61 | config['folder'] = sys.argv[4] |
47 | else: |
62 | elif hasUI: |
48 | config = ui.Dialog("Checkout Project", Folder=True, Credentials=True, DefaultFolder=folder) |
63 | config = ui.Dialog("Checkout Project", Folder=True, Credentials=True, DefaultFolder=folder) |
49 | 64 | ||
50 | # iterate over all tools of the project, and checkout all SVN repositories, |
65 | # iterate over all tools of the project, and checkout all SVN repositories, |
51 | # excluding the CODESYS folders |
66 | # excluding the CODESYS folders |
52 | if config != None: |
67 | if config != None: |
... |
... |
||
68 | f = open(os.path.join(config['folder'], repo + '.commit_count'), "w") |
83 | f = open(os.path.join(config['folder'], repo + '.commit_count'), "w") |
69 | if f: |
84 | if f: |
70 | f.write(str(details['commit_count'])) |
85 | f.write(str(details['commit_count'])) |
71 | f.close() |
86 | f.close() |