Diff of /codesys-ide/scripts/helper.py [8d987c] .. [9fd219]  Maximize  Restore

Switch to unified view

a/codesys-ide/scripts/helper.py b/codesys-ide/scripts/helper.py
1
###########################################################################################
1
###########################################################################################
2
# Helper classes for the different CI commands
2
# Helper classes for the different CI commands
3
###########################################################################################
3
###########################################################################################
4
import sys, os
4
import sys, os
5
import shutil
5
import shutil
6
from System.Net import WebClient
6
7
7
class SearchBuild:
8
class SearchBuild:
8
    def __init__(self):
9
    def __init__(self):
9
        self.artifacts = list()
10
        self.artifacts = list()
10
        self.error = False
11
        self.error = False
...
...
33
34
34
    # dummy rule
35
    # dummy rule
35
    def doit(self, filename):
36
    def doit(self, filename):
36
        artifacts = list()
37
        artifacts = list()
37
        return artifacts
38
        return artifacts
38
39
40
#
41
# Install a library from a URL (starting with http(s))
42
#
43
def install_library(url, librarymanager):
44
    if not url.startswith("http"):
45
        return
46
    
47
    downloaddir = os.path.join(os.environ["USERPROFILE"], "downloads")
48
    if not os.path.exists(downloaddir):
49
        os.makedirs(downloaddir)
50
    localname = os.path.join(downloaddir, "dl.library")
51
    print("*** download %s to %s\n" % (url, localname))
52
53
    web_client = WebClient()
54
    web_client.DownloadFile(url, localname)
55
    repo = librarymanager.repositories[0]
56
    print("*** installing %s\n" % url)
57
    librarymanager.install_library (localname, repo, True)
58
59
60
#
61
# Check if there is a *.requirements file, and install
62
# all requirements from there. The parameter is a library
63
# URL, while we are checking if a *.requirements file exists
64
# beside this library.
65
#
66
def install_requirements(library_filename, librarymanager):
67
    reqfilename = os.path.splitext(library_filename)[0] + ".requirements"
68
    
69
    if os.path.isfile(reqfilename):
70
        reqfile = open(reqfilename, "r")
71
        
72
        for req in reqfile:
73
            install_library(req, librarymanager)