mirror of
https://github.com/SystemRage/py-kms.git
synced 2024-11-10 17:49:37 +08:00
Add sys import, rename logger variable
This commit is contained in:
parent
096323f1c7
commit
c1fa1445d4
1 changed files with 9 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
# sqlite3 is optional.
|
# sqlite3 is optional.
|
||||||
try:
|
try:
|
||||||
|
@ -11,7 +12,7 @@ except ImportError:
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
logger = logging.getLogger('root')
|
loggersrv = logging.getLogger('logsrv')
|
||||||
|
|
||||||
def sql_initialize():
|
def sql_initialize():
|
||||||
dbName = 'clients.db'
|
dbName = 'clients.db'
|
||||||
|
@ -25,7 +26,7 @@ def sql_initialize():
|
||||||
licenseStatus TEXT, lastRequestTime INTEGER, kmsEpid TEXT, requestCount INTEGER)")
|
licenseStatus TEXT, lastRequestTime INTEGER, kmsEpid TEXT, requestCount INTEGER)")
|
||||||
|
|
||||||
except sqlite3.Error as e:
|
except sqlite3.Error as e:
|
||||||
logger.error("Error %s:" % e.args[0])
|
loggersrv.error("Error %s:" % e.args[0])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
finally:
|
finally:
|
||||||
if con:
|
if con:
|
||||||
|
@ -62,9 +63,10 @@ skuId, licenseStatus, lastRequestTime, requestCount) VALUES (:clientMachineId, :
|
||||||
cur.execute("UPDATE clients SET requestCount=requestCount+1 WHERE clientMachineId=:clientMachineId;", infoDict)
|
cur.execute("UPDATE clients SET requestCount=requestCount+1 WHERE clientMachineId=:clientMachineId;", infoDict)
|
||||||
|
|
||||||
except sqlite3.Error as e:
|
except sqlite3.Error as e:
|
||||||
logger.error("Error %s:" % e.args[0])
|
loggersrv.error("Error %s:" % e.args[0])
|
||||||
|
sys.exit(1)
|
||||||
except sqlite3.Error as e:
|
except sqlite3.Error as e:
|
||||||
logger.error("Error %s:" % e.args[0])
|
loggersrv.error("Error %s:" % e.args[0])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
finally:
|
finally:
|
||||||
if con:
|
if con:
|
||||||
|
@ -86,9 +88,10 @@ def sql_update_epid(dbName, kmsRequest, response):
|
||||||
cur.execute("UPDATE clients SET kmsEpid=? WHERE clientMachineId=?;", (str(response["kmsEpid"].decode('utf-16le')),
|
cur.execute("UPDATE clients SET kmsEpid=? WHERE clientMachineId=?;", (str(response["kmsEpid"].decode('utf-16le')),
|
||||||
cmid))
|
cmid))
|
||||||
except sqlite3.Error as e:
|
except sqlite3.Error as e:
|
||||||
logger.error("Error %s:" % e.args[0])
|
loggersrv.error("Error %s:" % e.args[0])
|
||||||
|
sys.exit(1)
|
||||||
except sqlite3.Error as e:
|
except sqlite3.Error as e:
|
||||||
logger.error("Error %s:" % e.args[0])
|
loggersrv.error("Error %s:" % e.args[0])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
finally:
|
finally:
|
||||||
if con:
|
if con:
|
||||||
|
|
Loading…
Reference in a new issue