Skip to content

Commit

Permalink
Add sys import, rename logger variable
Browse files Browse the repository at this point in the history
  • Loading branch information
SystemRage committed Oct 6, 2019
1 parent 096323f commit c1fa144
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions py-kms/pykms_Sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import logging
import sys

# sqlite3 is optional.
try:
Expand All @@ -11,7 +12,7 @@

#--------------------------------------------------------------------------------------------------------------------------------------------------------

logger = logging.getLogger('root')
loggersrv = logging.getLogger('logsrv')

def sql_initialize():
dbName = 'clients.db'
Expand All @@ -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:
Expand Down Expand Up @@ -62,9 +63,10 @@ def sql_update(dbName, infoDict):
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:
Expand All @@ -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:
Expand Down

0 comments on commit c1fa144

Please sign in to comment.