import os from sympy import * import uuid import time import math import re import arcpy def dataGet(s0): aa = 0 datekey = { 'ze':'0','im':'1','tw':'2','ee':'3','fr':'4','ve':'5', 'ix':'6','se':'7','ei':'8','ni':'9' } ii = 0 dastr = [] while ii < 8: x1 = 2 * ii y1 = x1 + 2 das = datekey[s0[x1:y1]] dastr.append(das) ii = ii + 1 datestr = ''.join(dastr) mm = int(datestr[:2]) dd = int(datestr[2:4]) yy = int(datestr[4:]) tm = time.localtime() dy = int(tm.tm_year) dm = int(tm.tm_mon) dday=int(tm.tm_mday) if dy < yy: aa = 1.7 elif dy == yy: if dm < mm: aa = 1.7 elif dm == mm: if dday <= dd: aa = 1.7 else: aa = -3 else: aa = -3 else: aa = -3 return aa def macget(sy0,ma0): mackey = { 'a':'10','b':'11','c':'12','d':'13','e':'14','f':'15' } aa = 0 sy = list(sy0) ma = list(ma0) ii = 0 node = uuid.getnode() MAC = uuid.UUID(int = node).hex[-12:] mac = MAC.lower() while ii < 4: try: syi = int(sy[ii]) mai = ma[ii] maci = mac[syi] if maci == mai: aa = 0 else: aa = -2 break except: syi = int(mackey[sy[ii]]) mai = ma[ii] maci = mac[syi] if maci == mai: aa = 0 else: aa = -2 break ii = ii + 1 if aa == 0: aa = 1.7 else: aa = -2 return aa def pdd(kk): n = Symbol('n') if kk > limit(((3*n*n - 5)/(2*n*n + n)),n,oo) and kk < (integrate(n**2,[n,0,1]) * 6): # ----------------这句才是程序运行代码---------------------------------- listfile(arcpy.GetParameterAsText(0),arcpy.GetParameterAsText(1)) # ----------------这句才是程序运行代码---------------------------------- elif kk == -1: arcpy.AddMessage ('\n') arcpy.AddMessage ('The License File Does Not Exist!') arcpy.AddMessage ('\n') elif kk == -2: arcpy.AddMessage ('License Password Error!') elif kk == -3: arcpy.AddMessage ('Out Of Permitted Time!') else: arcpy.AddMessage ('License File Corrupted!') def bsfGet(s0): aa = 0 bsfkey = { 'bd':'a','cd':'c','7a':'d','ae':'e','97':'g','6k':'h', '57':'i','22':'D','2c':'m','8m':'o','3w':'p','11':'I', '5d':'r','4u':'s','9t':'t','au':'u','23':'x','yk':'y', 'za':'z','k4':'0','v6':'1','tw':'2','h0':'5','op':'7', 'po':'8','wt':'9','8x':':','yy':',','lo':' ', } ii = 0 lens0 = len(s0) bsfstr = [] while ii < (lens0 / 2): x1 = 2 * ii y1 = x1 + 2 bsf = bsfkey[s0[x1:y1]] bsfstr.append(bsf) ii = ii + 1 bsstr = ''.join(bsfstr) return bsstr def licen(): aa = 0 linsy = '' linma = '' s1 = 'aucd8x' s2 = '3w5d8m7aaucd9tlo11228x' s3 = 'cd573w6kae5d8x' # path = 'D:\\CMCtbxLisence\\tbxLisence.txt' # isExists=os.path.exists(path) # if not isExists: # path1 = 'E:\\CMCtbxLisence\\tbxLisence.txt' # isExists1=os.path.exists(path1) # if not isExists1: # path2 = 'F:\\CMCtbxLisence\\tbxLisence.txt' # isExists2=os.path.exists(path2) # if not isExists2: # aa = -1 # else: # outpath = 'F:\\CMCtbxLisence\\tbxLisence.txt' # else: # outpath = 'E:\\CMCtbxLisence\\tbxLisence.txt' # else: # outpath = 'D:\\CMCtbxLisence\\tbxLisence.txt' outpath = os.path.expandvars("%APPDATA%") + '\\CMCtbxLisence\\tbxLisence.txt' isExists = os.path.exists(outpath) if not isExists: aa = -1 if aa != -1: with open(outpath,'r') as lines: for line in lines: t = bsfGet(s1) if re.search(bsfGet(s1),line): try: linrq1 = line.split(':',-1)[-1] linrq = linrq1.replace('\n','') aa = dataGet(linrq) if aa == -3: break except: aa = -9999 if re.search(bsfGet(s2),line): try: linSY1 = line.split('-',-1)[-1] linSY = linSY1.replace('\n','') linsy = linSY.lower() except: aa = -9999 if re.search(bsfGet(s3),line): try: linma1 = line.split('-',-1)[0] linMA1 = linma1.split(':',-1)[-1] linMA = linMA1.replace('\n','') linma = linMA.lower() aa = macget(linsy,linma) except: aa = -9999 else: aa = -1 pdd(aa) if __name__ == '__main__': try: arcpy.AddMessage ('start at {0}\n'.format(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))) licen() arcpy.AddMessage ('end at {0}\n'.format(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))) except arcpy.ExecuteError: arcpy.AddMessage (arcpy.GetMessages())