修改下面程式碼的變數ip為license manager安裝的電腦IP,接著在AEDT當中Run Script即可。幾秒鐘後便會跳出notepad顯示user.log,如圖一。
import os
import re
ip='locahost'
os.chdir(os.path.dirname(__file__))
os.environ['path']+=';{}'.format(oDesktop.GetExeDir())
os.environ['path']+=';{}\licensingclient\winx64'.format(oDesktop.GetExeDir())
os.system('lmutil lmstat -a -c 1055@{} > license_usage.log'.format(ip.strip()))
with open('license_usage.log') as f:
text = f.readlines()
usage_info = []
flag = False
for i in text:
if len(i.strip())==0 or 'floating license' in i:
continue
if i.startswith('Users'):
flag = False
continue
m = re.search('"(\w*?)"', i)
if m:
feature = m.group(1)
flag = True
continue
if flag == True:
if i.endswith('licenses\n'):
user, machine = i.split()[0:2]
number = i.split()[-2]
usage_info.append('{:36}{:12}{:>24} x{:<3}\n'.format(machine, user, feature, number))
else:
try:
user, machine = i.split()[0:2]
usage_info.append('{:36}{:12}{:>24} x{:<3}\n'.format(machine, user, feature, 1))
except:
pass
usage_info.sort()
with open('user.log', 'w') as f:
f.writelines(usage_info)
os.system('notepad user.log')
(圖一) 電腦、使用者、license及使用數量 |