搞定了,修改了licgen.py文件:
把报错的地方都屏蔽了,更新后内容如下:
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 26 10:34:42 2012
@author: netiger74
"""
"""
For Novas_single.exe, to generate lics check if ck<100
if ck>100, change expiredate,rerun novas_single.exe
features are read from features.lst
format as
firstline: hostid version expiredate licnumbers ckmax
feature
final results are wrote in license.dat
"""
import os
#from numpy import *
sCMD = "novas_single.exe"
sLicGen = "novas_license_v6.0.txt"
exDay = "1"
exMon = "dec"
exYear = "2014"
sVer = "2013.04"
sUser = "20"
sFileOut = "license.dat"
nCKMax = 100
#try:
fFeatures = open('features.lst')
#except Exception,e:
# print 'features.lst open file error:',e
# print 'Please check it!\n'
# exit()
fLines = fFeatures.readlines()
baseLine0 = fLines[0]
head = baseLine0.split()
for i,item in enumerate(head):
if i==0:
sHostid = head[i]
elif i==1:
sVer = head[i]
elif i==2:
sDate = head[i]
sDate = sDate.replace('-',' ')
datelst = sDate.split()
#exDay = datelst[0]
exMon = datelst[1]
exYear = datelst[2]
elif i==3:
sUser = head[i]
elif i==4:
nCKMax = int(head[i])
else:
break
#if sHostid.__len__()<>12:
# print 'Invalid HostID:',sHostid
# print 'please check feature.lst'
# fFeatures.close()
# exit()
features = fLines[1:]
#try:
foutput = open(sFileOut,'w')
#except Exception,e:
# print 'license.dat open file error:',e
# exit()
for feature in features:
goodlic = 0
while not goodlic:
fullcmd = sCMD+' -V'+sVer+' -U'+sUser+' -E'+exDay+'-'+exMon+'-'+exYear+ ' -M'+sHostid+' -F'+feature
os.system(fullcmd)
# try:
flicgen = open(sLicGen)
# except Exception,e:
# print 'License file open fail'
# exit()
tlines = flicgen.readlines()
lck = tlines[3] if tlines[3].find('ck=') > 0 else tlines[4]
lck = lck.strip('\t\n')
listck = lck.split('=')
ckval = int(listck[-1])
goodlic = 1 if ckval < nCKMax else 0
if goodlic == 1:
foutput.writelines(tlines[2:])
else:
exDay = str(int(exDay)+1)
# if int(exDay) >31:
# print feature," licgen failed"
# goodlic=1
# exDay='1'
flicgen.close()
#flicgen.close()
fFeatures.close()
foutput.close()
exit() |