<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/</id><updated>2020-07-14T09:19:57.050000Z</updated><subtitle>Recent posts to Scripting automatic downloading of missing libraries</subtitle><entry><title>Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/?limit=250#6f62/d0f4/e00d/1f0a" rel="alternate"/><published>2020-07-14T09:19:57.050000Z</published><updated>2020-07-14T09:19:57.050000Z</updated><author><name>aliazzz</name><uri>https://forge.codesys.com/u/aliazzz/</uri></author><id>https://forge.codesys.com39d443b880f336f9fb251cb5d5eafe05bbc4d6bc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;In the upper-right there is a Hamburger Menu button. &lt;br/&gt;
See the attached .png for hints&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/?limit=25#6f62/d0f4/e00d" rel="alternate"/><published>2020-07-14T08:45:23.677000Z</published><updated>2020-07-14T08:45:23.677000Z</updated><author><name>jelle</name><uri>https://forge.codesys.com/u/jelle/</uri></author><id>https://forge.codesys.com2bb0ac1086e5a727d8d1d997f603e2eb42810127</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Do you have a link? I am not aware that there is a central place to share scripts&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/?limit=250#6f62/d0f4" rel="alternate"/><published>2020-07-14T08:38:42.295000Z</published><updated>2020-07-14T08:38:42.295000Z</updated><author><name>aliazzz</name><uri>https://forge.codesys.com/u/aliazzz/</uri></author><id>https://forge.codesys.com80b152e2c463793bcb41a038a1bf6654785d159f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Why don't you submit these under tools, scripts, that way they are easy to find for any interested user, I hope you understand and many thanks for sharing them with us.&lt;/p&gt;
&lt;p&gt;Ps have you got a solution for generating a project archive in headless Codesys mode too? In the version I am using it does not work.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/?limit=25#6f62" rel="alternate"/><published>2020-07-14T06:53:14.162000Z</published><updated>2020-07-14T06:53:14.162000Z</updated><author><name>jelle</name><uri>https://forge.codesys.com/u/jelle/</uri></author><id>https://forge.codesys.come0857a855c69d475f078d78025cf206de109e660</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Some snippets that are interesting :)&lt;/p&gt;
&lt;p&gt;Script that lists all the library dependencies:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;proj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;projects&lt;/span&gt;.&lt;span class="nv"&gt;open&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;projectPath&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;objects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;proj&lt;/span&gt;.&lt;span class="nv"&gt;get_children&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;recursive&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;True&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;candidate&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;objects&lt;/span&gt;:
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;candidate&lt;/span&gt;.&lt;span class="nv"&gt;is_libman&lt;/span&gt;:
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;libref&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;iter&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;candidate&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;libref&lt;/span&gt;.&lt;span class="nv"&gt;is_placeholder&lt;/span&gt;:
                    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;libref&lt;/span&gt;.&lt;span class="nv"&gt;effective_resolution&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;not&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;:
                        &lt;span class="nv"&gt;libInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;str&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;libref&lt;/span&gt;.&lt;span class="nv"&gt;effective_resolution&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
                        &lt;span class="nv"&gt;libMissing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;False&lt;/span&gt;
                    &lt;span class="nv"&gt;elif&lt;/span&gt; &lt;span class="nv"&gt;libref&lt;/span&gt;.&lt;span class="nv"&gt;default_resolution&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;not&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;:
                        &lt;span class="nv"&gt;libInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;str&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;libref&lt;/span&gt;.&lt;span class="nv"&gt;default_resolution&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
                        &lt;span class="nv"&gt;libMissing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;True&lt;/span&gt;
                &lt;span class="nv"&gt;elif&lt;/span&gt; &lt;span class="nv"&gt;libref&lt;/span&gt;.&lt;span class="nv"&gt;is_managed&lt;/span&gt;:   
                    &lt;span class="nv"&gt;libInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;str&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;libref&lt;/span&gt;.&lt;span class="nv"&gt;managed_library&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;else&lt;/span&gt;:               
                    &lt;span class="nv"&gt;libInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;str&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;libref&lt;/span&gt;.&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;            
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Script that downloads the libraries:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;libraryServers&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; [&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://store.codesys.com/CODESYSLibs/&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;]
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;server&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;libraryServers&lt;/span&gt;:
                &lt;span class="nv"&gt;libraryFileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;
                &lt;span class="nv"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;str&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;%s%s/%s/%s/&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;server&lt;/span&gt;, &lt;span class="nv"&gt;data&lt;/span&gt;[&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;supplier&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;], &lt;span class="nv"&gt;data&lt;/span&gt;[&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;], &lt;span class="nv"&gt;data&lt;/span&gt;[&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;version&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;]&lt;span class="ss"&gt;))&lt;/span&gt;
                &lt;span class="nv"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;requests&lt;/span&gt;.&lt;span class="nv"&gt;get&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;url&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;index&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
            &lt;span class="nv"&gt;fileUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;str&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;%s%s&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;url&lt;/span&gt;, &lt;span class="nv"&gt;libraryFileName&lt;/span&gt;&lt;span class="ss"&gt;))&lt;/span&gt;.&lt;span class="nv"&gt;rstrip&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;
            &lt;span class="nv"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;requests&lt;/span&gt;.&lt;span class="nv"&gt;get&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;fileUrl&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
            &lt;span class="nv"&gt;f&lt;/span&gt;.&lt;span class="nv"&gt;write&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;response&lt;/span&gt;.&lt;span class="nv"&gt;content&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Script that installs the downloaded libraries:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;librarymanager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;repositories&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;librarymanager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;install_library&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;absLibPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;overwrite&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/?limit=250#1067" rel="alternate"/><published>2020-07-13T18:14:52.184000Z</published><updated>2020-07-13T18:14:52.184000Z</updated><author><name>aliazzz</name><uri>https://forge.codesys.com/u/aliazzz/</uri></author><id>https://forge.codesys.com727abe3e3d5a0af1ddc0ddc6c8a136a88f51d0f3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, would you be so kind to share the scripts with us?&lt;br/&gt;
That would be very nice if you did! ;-)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/?limit=25#67d1" rel="alternate"/><published>2020-07-13T15:37:40.347000Z</published><updated>2020-07-13T15:37:40.347000Z</updated><author><name>jelle</name><uri>https://forge.codesys.com/u/jelle/</uri></author><id>https://forge.codesys.combddd8774174faeb49a6d7d8405bd9c4bff38e3f1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I solved the issue by creating 3 scripts:&lt;br/&gt;
1. script that lists all library dependencies&lt;br/&gt;
2. script in Python 3 that downloads the missing libraries&lt;br/&gt;
3. script that install the missing libraries&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/?limit=25#8f24/f01b" rel="alternate"/><published>2020-07-03T08:01:42.432000Z</published><updated>2020-07-03T08:01:42.432000Z</updated><author><name>jelle</name><uri>https://forge.codesys.com/u/jelle/</uri></author><id>https://forge.codesys.com6179a21f5413c58778c28f596e37c93f71627cf5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Good advice as workaround but I am searching for an answer to my question.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/?limit=25#8f24" rel="alternate"/><published>2020-07-02T17:51:50.205000Z</published><updated>2020-07-02T17:51:50.205000Z</updated><author><name>bhess</name><uri>https://forge.codesys.com/u/bhess/</uri></author><id>https://forge.codesys.com518e3832cbb757d40f255a16ea88ab2e95b39050</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I recommend sabing your project as an archive before opening on the build PC, as this will save every device description and library required to build it so no downloading is needed.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Scripting automatic downloading of missing libraries</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/59878cec74/?limit=25#83a6" rel="alternate"/><published>2020-07-02T15:20:26.804000Z</published><updated>2020-07-02T15:20:26.804000Z</updated><author><name>jelle</name><uri>https://forge.codesys.com/u/jelle/</uri></author><id>https://forge.codesys.com5e2d5acc6a57fe5aa2e7f6d4d2ace51cac94589f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have been trying to automatically resolve missing libraries on our build PC.&lt;/p&gt;
&lt;p&gt;First I searched the forum and found some old topics that are relevant to automate CoDeSys prompts:&lt;br/&gt;
- &lt;a href="https://forge.codesys.com/forge/talk/Engineering/thread/cb4c263657/"&gt;https://forge.codesys.com/forge/talk/Engineering/thread/cb4c263657/&lt;/a&gt;&lt;br/&gt;
- &lt;a href="https://forge.codesys.com/forge/talk/Engineering/thread/bf6c8291a5/"&gt;https://forge.codesys.com/forge/talk/Engineering/thread/bf6c8291a5/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The following is now implemented as Python script that runs in CoDeSys V3.5 SP16:&lt;br/&gt;
system.prompt_handling |= PromptHandling.LogMessageKeys&lt;br/&gt;
system.prompt_handling &amp;amp;= ~PromptHandling.ForwardSimplePrompts&lt;/p&gt;
&lt;p&gt;system.prompt_answers&lt;span&gt;["DownloadMissingLibrariesDialog_Prompt"]&lt;/span&gt;=PromptResult.OK&lt;br/&gt;
system.commands&lt;span&gt;["libman","opendownloadmissinglibrariesdialog"]&lt;/span&gt;.execute()&lt;/p&gt;
&lt;p&gt;I expect now that I can automate the "Download" button in the prompted window. But it does not work and also the prompt message key is not logged.&lt;/p&gt;
&lt;p&gt;I am now completely stuck. Can anyone please help.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>