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 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: