a | b/trunk/cforge/cforge/Package/CFORGE/Scripts/install.py | ||
---|---|---|---|
1 | # imports |
||
2 | import sys |
||
3 | |||
4 | |||
5 | from System.Diagnostics import Process |
||
6 | from System.Diagnostics import Debugger |
||
7 | from System.IO import Path |
||
8 | from System.Net import WebClient |
||
9 | |||
10 | #Debugger.Break() |
||
11 | # |
||
12 | # This is a cforge command (script file) |
||
13 | # this will be run as ironpython script. |
||
14 | # the filename of this script is automatically the corresponding cforge command |
||
15 | # with some magic functions you can easily integrate it nicely into cforge tool |
||
16 | |||
17 | # cforge_usage: |
||
18 | # here you can return an array of all possible arguments and options that can |
||
19 | # be passed to this command script |
||
20 | def cforge_usage(): |
||
21 | help = [ |
||
22 | ["<url_to_package>", "download and install a codesys package"], |
||
23 | ["<local path of package>", "install a local codesys package"] |
||
24 | ] |
||
25 | |||
26 | return help |
||
27 | |||
28 | |||
29 | |||
30 | print("command install running") |
||
31 | print("Arguments: " + str(len(sys.argv))) |
||
32 | for a in sys.argv: |
||
33 | print(a) |
||
34 | |||
35 | |||
36 | # download |
||
37 | |||
38 | localpath = Path.GetFilename(sys.argv[0]) |
||
39 | url = sys.argv[0] |
||
40 | |||
41 | web_client = WebClient() |
||
42 | web_client.DownloadFile(url, localpath) |
||
43 | |||
44 | |||
45 | # and install local package now: |
||
46 | Process.Start(localpath) |
||
47 | |||
48 | |||
49 | |||
50 |