<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Ticket search results</title><link>https://forge.codesys.com/tol/scripting/snippets/</link><description>You searched for labels:"libraries missing download install"</description><language>en</language><lastBuildDate>Tue, 14 Jul 2020 11:16:24 -0000</lastBuildDate><item><title>Installation of missing libraries</title><link>https://forge.codesys.com/tol/scripting/snippets/18/</link><description>Script that lists all the library dependencies:
~~~
proj = projects.open(projectPath)
objects = proj.get_children(recursive=True)
    for candidate in objects:
        if candidate.is_libman:
            for libref in iter(candidate):
                if libref.is_placeholder:
                    if libref.effective_resolution is not None:
                        libInfo = str(libref.effective_resolution)
                        libMissing = False
                    elif libref.default_resolution is not None:
                        libInfo = str(libref.default_resolution)
                        libMissing = True
                elif libref.is_managed:   
                    libInfo = str(libref.managed_library)
                else:               
                    libInfo = str(libref.name)   
~~~
         
Script that downloads the libraries:
~~~
libraryServers  = ["https://store.codesys.com/CODESYSLibs/"]
            for server in libraryServers:
                libraryFileName = None
                url = str("%s%s/%s/%s/" % (server, data['supplier'], data['name'], data['version']))
                response = requests.get(url + "index")
            fileUrl = str("%s%s" % (url, libraryFileName)).rstrip()
            response = requests.get(fileUrl)
            f.write(response.content)
~~~

Script that installs the downloaded libraries:
~~~
repo = librarymanager.repositories[0]
librarymanager.install_library(absLibPath, repo, overwrite=True)
~~~

</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jelle</dc:creator><pubDate>Tue, 14 Jul 2020 11:16:24 -0000</pubDate><guid isPermaLink="false">https://forge.codesys.com/tol/scripting/snippets/18/</guid></item></channel></rss>