Check availability of floating license
    20 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Patrick Schmale
 le 21 Avr 2017
  
    
    
    
    
    Commenté : Davide Allaio
 le 14 Mar 2023
            We are using MATLAB/Simulink floating license for continous integration. We've got the problem that MATLAB/Simulink ends up with an license checkout failed error, if no floating license is available. Is there a way to check if a license is a available before starting MATLAB/Simulink?
0 commentaires
Réponse acceptée
  Antonios Pournaras
      
 le 27 Juil 2018
        Here is a python function that prints how many licences are available and returns in this case. If there are no licenses available it tries again. The function calls the system command "lmutil" which is a license administration utility installed along with MATLAB. It writes the output to a file 'mat_lic.info'. Parses this file until it finds a line where there is information about the licence. Always check this file because its format may change through different MATLAB versions and the script needs modification. It works for MATLAB R2014b:
import subprocess
def matlab_license():
  while True:
    # substitute port and server with correct values
    # lmutil may not be in path. Put the whole path instead.
    lic_server=['lmutil','lmstat','-a','-c','port@server']
    cmdout = subprocess.check_output(lic_server)
    F=open('mat_lic.info','w')
    F.write(cmdout)
    F.close()
    F=open('mat_lic.info','r')
    for line in F:
      if 'Users of MATLAB' in line:
        text = line
        break
    F.close()
    num=[]
    for word in text.split():
      if word.isdigit():
        num.append(word)
    lic_avail = max(num) - min(num)
    if lic_avail  < 2:
       print "Only %d licence(s) found. Trying again." % lic_avail 
    else:
       print "Found %d licenses availabe." % lic_avail
       return
2 commentaires
  Patrick Schmale
 le 6 Août 2018
				
      Modifié(e) : Patrick Schmale
 le 6 Août 2018
  
			
		
  Davide Allaio
 le 14 Mar 2023
				Hello, I know it has been 5 years already, but could someone explain to me how to modify the lic_server string correctly in order for the function to work? Thank you very much!!
Plus de réponses (1)
Voir également
Catégories
				En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



