CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Mon Nov 19, 2018 10:01 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Jul 19, 2017 10:37 am 
Offline

Joined: Mon Oct 20, 2014 7:05 am
Posts: 9
How can a libary be removed by python script from the CODESYS library repository?

Can you give me an example for that?

Thanks in advance...


Top
   
PostPosted: Wed Jul 19, 2017 6:05 pm 
Offline

Joined: Wed Dec 28, 2016 11:00 pm
Posts: 65
I am also interested in such an example


Top
   
PostPosted: Thu Jul 20, 2017 9:19 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 232
Hi DBaur.

DBaur wrote:
How can a libary be removed by python script from the CODESYS library repository?

Can you give me an example for that?

Here my example code:
Code:
print("Find library...")
found = librarymanager.find_library("TestLib, 1.0.0.0 (3S-Smart Software Solutions GmbH)")

if found:
   lib, repo = found
   print("Lib: " + lib.displayname)
   print("In repo: {} ({})".format(repo.name, repo.root_folder))

   print("Uninstall library...")
   librarymanager.uninstall_library(repo, lib)

   found = librarymanager.find_library("TestLib, 1.0.0.0 (3S-Smart Software Solutions GmbH)")
   if found:
      print("Error: Lib ist still there!!!")
else:
   print("NO lib was found")

BR
Martin

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Wed Apr 04, 2018 7:29 pm 
Offline
User avatar

Joined: Mon Jan 16, 2017 3:10 pm
Posts: 8
Hi Martin

Is it possible to find a library only by company?
So I can uninstall all libraries form one company.
Code:
found = librarymanager.find_library("*, * (Siemens)")


Thanks


Top
   
PostPosted: Tue May 29, 2018 3:24 pm 
Offline

Joined: Tue Oct 14, 2014 1:38 pm
Posts: 8
feragfh6 wrote:
Hi Martin

Is it possible to find a library only by company?
So I can uninstall all libraries form one company.
Code:
found = librarymanager.find_library("*, * (Siemens)")


Thanks



I might be too late, but here it is:
Code:
#-*- coding: UTF-8 -*-
from __future__ import print_function
import sys, os
from sys import exit

libRepository = librarymanager
defaultRepository = libRepository.repositories[0]

def removeAllCompanyLibs(sCompanyName):
   sCompanyName = sCompanyName.upper()
   for repository in libRepository.repositories:
      for library in libRepository.get_all_libraries(repository):
         if sCompanyName in library.company.upper():
            system.write_message(Severity.Information, 'Lib removed: ' + library.displayname)
            libRepository.uninstall_library (repository, library)
   system.write_message(Severity.Information, 'Removing libraries done')

removeAllCompanyLibs ('siemens')

you might improve the line where library company is compared to your:
Code:
if sCompanyName in library.company.upper():


Top
   
PostPosted: Wed May 30, 2018 11:06 am 
Offline
User avatar

Joined: Mon Jan 16, 2017 3:10 pm
Posts: 8
Works. Thanks.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited