Add sys import, rename logger variable

This commit is contained in:
Matteo ℱan 2019-10-06 22:12:00 +02:00
parent 096323f1c7
commit c1fa1445d4

View File

@ -2,6 +2,7 @@
import os
import logging
import sys
# sqlite3 is optional.
try:
@ -11,7 +12,7 @@ except ImportError:
#--------------------------------------------------------------------------------------------------------------------------------------------------------
logger = logging.getLogger('root')
loggersrv = logging.getLogger('logsrv')
def sql_initialize():
dbName = 'clients.db'
@ -25,7 +26,7 @@ def sql_initialize():
licenseStatus TEXT, lastRequestTime INTEGER, kmsEpid TEXT, requestCount INTEGER)")
except sqlite3.Error as e:
logger.error("Error %s:" % e.args[0])
loggersrv.error("Error %s:" % e.args[0])
sys.exit(1)
finally:
if con:
@ -62,9 +63,10 @@ skuId, licenseStatus, lastRequestTime, requestCount) VALUES (:clientMachineId, :
cur.execute("UPDATE clients SET requestCount=requestCount+1 WHERE clientMachineId=:clientMachineId;", infoDict)
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:
logger.error("Error %s:" % e.args[0])
loggersrv.error("Error %s:" % e.args[0])
sys.exit(1)
finally:
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')),
cmid))
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:
logger.error("Error %s:" % e.args[0])
loggersrv.error("Error %s:" % e.args[0])
sys.exit(1)
finally:
if con: