@@ -76,10 +76,12 @@ def __init__(self):
7676 parser .add_argument ('ManageProject' , help = 'VectorCAST Project Name' )
7777 parser .add_argument ('-j' ,'--jobs' , help = 'Number of concurrent jobs (default = maximun license count or processor)' , default = "max" )
7878 parser .add_argument ('--ci' , help = 'Use Continuous Integration Licenses' , action = "store_true" , default = False )
79+ parser .add_argument ('-v' , '--verbose' , help = 'Enable verbose output' , action = "store_true" , default = False )
7980
8081 args = parser .parse_args ()
8182
8283 self .mpName = args .ManageProject
84+ self .verbose = args .verbose
8385
8486 self .api = VCProjectApi (self .mpName )
8587 self .results = self .api .project .repository .get_full_status ([])
@@ -154,37 +156,61 @@ def getLicenseCount(self):
154156 from datetime import datetime
155157 import re
156158
157- cmd = r'"C:\Program Files (x86)\Vector License Client\Vector.LicenseClient.exe" -listlicenses -network'
159+ if os .path .exists (r'C:\Program Files\Vector License Client\Vector.LicenseClient.exe' ):
160+ cmd = r'"C:\Program Files\Vector License Client\Vector.LicenseClient.exe" -listlicenses'
161+ elif os .path .exists (r'C:\Program Files (x86)\Vector License Client\Vector.LicenseClient.exe' ):
162+ cmd = r'"C:\Program Files (x86)\Vector License Client\Vector.LicenseClient.exe" -listlicenses'
163+ else :
164+ print ("Cannot find the Vector License Client - setting license count to 1" )
165+ return 1
166+
158167 process = subprocess .Popen (cmd , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
159168 stdout , stderr = process .communicate ()
169+
170+ if len (stderr ) > 0 :
171+ print (f"Error occurredn\{ stdout } \n { stderr } " )
172+
173+ raw = stdout
174+ raw = re .sub (rb'encoding\s*=\s*"(.*?)"' , b'encoding="UTF-8"' , raw , count = 1 )
175+ xml_data = raw .decode ("utf-8" , errors = "replace" )
160176
161- xml_data = stdout
177+ if self .verbose :
178+ print (f"{ xml_data } " )
162179
163180 # Parse XML
164- root = ET .fromstring (xml_data )
165181
182+ try :
183+ root = ET .fromstring (xml_data )
184+ except Eception as e :
185+ print (f"Error with { xml_data } " )
186+ import traceback
187+ print ("Exception in root = ET.fromstring(xml_data):" , traceback .format_exc ())
188+ return 1
189+
166190 now = datetime .now ()
167191 if os .environ .get ("VCAST_USE_CI_LICENSES" ) is not None or os .environ .get ("VCAST_USING_HEADLESS_MODE" ) is not None :
168- searchType = "Server Edition"
192+ searchType = [ "Server Edition" , "SE" ]
169193 else :
170- searchType = "Desktop Edition"
194+ searchType = [ "Desktop Edition" , "DE" ]
171195
172196 free_list = []
197+
173198 # Loop through all VectorLicense nodes
174199 for lic in root .findall ('.//VectorLicense' ):
175200 product_text = lic .find ('ProductText' )
176201 expiration_text = lic .find ('ExpirationDateString' )
177- free_licenses = lic .find ('FreeLicenses ' )
202+ free_licenses = lic .find ('Quantity ' )
178203
179204 if product_text is not None and expiration_text is not None and free_licenses is not None :
180205 product = product_text .text .strip ()
206+ product_type = product_text .text .strip ().split ()[1 ]
181207 expiration = expiration_text .text .strip ()
182208 free = int (free_licenses .text .strip ())
183209
184210 if re .match (r'^VectorCAST.*' , product ):
185211 exp_date = datetime .strptime (expiration , "%Y-%m-%dT%H:%M:%S" )
186212 if exp_date > now :
187- if searchType in product :
213+ if product_type in searchType :
188214 free_list .append (free )
189215
190216
0 commit comments