Search Project: *:*

 
<< < 1 .. 1154 1155 1156 1157 1158 .. 3647 > >> (Page 1156 of 3647)

wiki Discussion janenalleman wiki (Discussion)
Forum for wiki comments
Last updated: 2020-09-20

blog Discussion janenalleman blog (Discussion)
Forum for blog comments
Last updated: 2020-09-20

Post by ingo on #19 Install missing libraries Scripting snippets (Post)
Description has changed: Diff: --- old +++ new @@ -35,8 +35,6 @@ proj = projects.primary # compile a regular expression to match lib placeholders p = re.compile(&#39;[^,]+, [^(]+\([^)]+\)&#39;) - # Breakpoint Logging Functions, 3.5.5.0 (3S - Smart Software Solutions GmbH) - # search for libman objects = proj.get_children(recursive=True)
Last updated: 2020-09-20

(no subject) Scripting snippets (Thread)
Last updated: 2020-09-20

Ticket #19: Install missing libraries Scripting snippets (Ticket)
Thanks @jelle for the ideas I got from snippet [#18]. But as the snippet from @jelle was not complete, yet, a lot of transfer knowledge was necessary to use it. So after I implemented it by myself, I thought, that I should add my version here also. It acts on the primary project. So you should open the project before calling this function. And it uses WebClient from DotNet, because the "request" module, which was referenced in [#18] was not available. import os, re from System.Net import WebClient # # Install a library from a URL (starting with http(s)) # def install_library(url, librarymanager): if not url.startswith("http"): return downloaddir = os.path.join(os.environ["USERPROFILE"], "downloads") if not os.path.exists(downloaddir): os.makedirs(downloaddir) basename, extension = os.path.splitext(url) localname = os.path.join(downloaddir, "dl" + extension) print("*** download %s to %s\n" % (url, localname)) web_client = WebClient() web_client.DownloadFile(url, localname) repo = librarymanager.repositories[0] print("*** installing %s\n" % url) librarymanager.install_library (localname, repo, True) # # search for missing libraries in current primary project # def install_missing_libraries(librarymanager): proj = projects.primary # compile a regular expression to match lib placeholders p = re.compile('[^,]+, [^(]+\([^)]+\)') # search for libman objects = proj.get_children(recursive=True) for object in objects: if object.is_libman: for libref in iter(object): if libref.is_placeholder: if libref.effective_resolution is None and libref.default_resolution is not None: libInfo = str(libref.default_resolution) m = re.findall('([^,]+), ([^(]+) \(([^)]+)\)', libInfo) if len(m) > 0: libname, libversion, libvendor = m[0] indexurl = "https://store.codesys.com/CODESYSLibs/%s/%s/%s/index" % (libvendor, libname, libversion) web_client = WebClient() try: filename = web_client.DownloadString(indexurl).rstrip() except: filename = None if filename != None: liburl = "https://store.codesys.com/CODESYSLibs/%s/%s/%s/%s" % (libvendor, libname, libversion, filename) install_library(liburl, librarymanager) The function can be called like this: install_missing_libraries(librarymanager) The variable "librarymanager" is implicitly available in python scripts, running in CODESYS.Install missing libraries Scripting 0 snippets Ticket tickets Install missing libraries 2020-09-20 19:27:40.626000 Unlicense False 0 ingo Ticket #19: Install missing libraries 0 False /tol/scripting/snippets/19/ ingo 2020-09-20 19:12:54.499000 None 19 scripting Thanks @jelle for the ideas I got from snippet [#18]. But as the snippet from @jelle was not complete, yet, a lot of transfer knowledge was necessary to use it. So after I implemented it by myself, I thought, that I should add my version here also. It acts on the primary project. So you should open the project before calling this function. And it uses WebClient from DotNet, because the "request" module, which was referenced in [#18] was not available. import os, re from System.Net import WebClient # # Install a library from a URL (starting with http(s)) # def install_library(url, librarymanager): if not url.startswith("http"): return downloaddir = os.path.join(os.environ["USERPROFILE"], "downloads") if not os.path.exists(downloaddir): os.makedirs(downloaddir) basename, extension = os.path.splitext(url) localname = os.path.join(downloaddir, "dl" + extension) print("*** download %s to %s\n" % (url, localname)) web_client = WebClient() web_client.DownloadFile(url, localname) repo = librarymanager.repositories[0] print("*** installing %s\n" % url) librarymanager.install_library (localname, repo, True) # # search for missing libraries in current primary project # def install_missing_libraries(librarymanager): proj = projects.primary # compile a regular expression to match lib placeholders p = re.compile('[^,]+, [^(]+\([^)]+\)') # search for libman objects = proj.get_children(recursive=True) for object in objects: if object.is_libman: for libref in iter(object): if libref.is_placeholder: if libref.effective_resolution is None and libref.default_resolution is not None: libInfo = str(libref.default_resolution) m = re.findall('([^,]+), ([^(]+) \(([^)]+)\)', libInfo) if len(m) > 0: libname, libversion, libvendor = m[0] indexurl = "https://store.codesys.com/CODESYSLibs/%s/%s/%s/index" % (libvendor, libname, libversion) web_client = WebClient() try: filename = web_client.DownloadString(indexurl).rstrip() except: filename = None if filename != None: liburl = "https://store.codesys.com/CODESYSLibs/%s/%s/%s/%s" % (libvendor, libname, libversion, filename) install_library(liburl, librarymanager) The function can be called like this: install_missing_libraries(librarymanager) The variable "librarymanager" is implicitly available in python scripts, running in CODESYS. False False 2
Last updated: 2020-09-20

Home janenalleman wiki (WikiPage)
This is the personal project of janenalleman. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2020-09-20

(no subject) janenalleman wiki (Thread)
Last updated: 2020-09-20

Home thanawat-p wiki (WikiPage)
This is the personal project of thanawat-p. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2020-09-21

wiki Discussion thanawat-p wiki (Discussion)
Forum for wiki comments
Last updated: 2020-09-21

blog Discussion thanawat-p blog (Discussion)
Forum for blog comments
Last updated: 2020-09-21

(no subject) thanawat-p wiki (Thread)
Last updated: 2020-09-21

Home mlamp wiki (WikiPage)
This is the personal project of mlamp. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2020-09-21

wiki Discussion mlamp wiki (Discussion)
Forum for wiki comments
Last updated: 2020-09-21

blog Discussion mlamp blog (Discussion)
Forum for blog comments
Last updated: 2020-09-21

blog Discussion psch blog (Discussion)
Forum for blog comments
Last updated: 2020-09-21

(no subject) mlamp wiki (Thread)
Last updated: 2020-09-21

Home psch wiki (WikiPage)
This is the personal project of psch. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2020-09-21

wiki Discussion kunbussupport wiki (Discussion)
Forum for wiki comments
Last updated: 2020-09-21

blog Discussion kunbussupport blog (Discussion)
Forum for blog comments
Last updated: 2020-09-21

wiki Discussion psch wiki (Discussion)
Forum for wiki comments
Last updated: 2020-09-21

(no subject) psch wiki (Thread)
Last updated: 2020-09-21

Home kunbussupport wiki (WikiPage)
This is the personal project of kunbussupport. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2020-09-21

(no subject) kunbussupport wiki (Thread)
Last updated: 2020-09-21

wiki Discussion yjy116 wiki (Discussion)
Forum for wiki comments
Last updated: 2020-09-21

<< < 1 .. 1154 1155 1156 1157 1158 .. 3647 > >> (Page 1156 of 3647)

Showing results of 91171

Sort by relevance or date