mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-13 06:34:45 -04:00
var added as requested and renamed as per PEP-008
https://www.python.org/dev/peps/pep-0008/#function-and-variable-names
This commit is contained in:
parent
2979e78311
commit
51e2210e72
1 changed files with 10 additions and 7 deletions
|
@ -24,18 +24,21 @@ sqliteWebPath = '/home/sqlite_web/sqlite_web.py'
|
||||||
enableSQLITE = os.path.isfile(sqliteWebPath) and os.environ.get('SQLITE', 'false').lower() == 'true'
|
enableSQLITE = os.path.isfile(sqliteWebPath) and os.environ.get('SQLITE', 'false').lower() == 'true'
|
||||||
dbPath = os.path.join(os.sep, 'home', 'py-kms', 'db', 'pykms_database.db')
|
dbPath = os.path.join(os.sep, 'home', 'py-kms', 'db', 'pykms_database.db')
|
||||||
log_level = os.getenv('LOGLEVEL', 'INFO')
|
log_level = os.getenv('LOGLEVEL', 'INFO')
|
||||||
|
log_file = os.environ.get('LOGFILE', 'STDOUT')
|
||||||
|
listen_ip = os.environ.get('IP', '0.0.0.0')
|
||||||
|
listen_port = os.environ.get('PORT', '1688')
|
||||||
|
sqlite_port = os.environ.get('SQLITE_PORT', '8080')
|
||||||
|
|
||||||
|
|
||||||
def start_kms_client():
|
def start_kms_client():
|
||||||
if not os.path.isfile(dbPath):
|
if not os.path.isfile(dbPath):
|
||||||
# Start a dummy activation to ensure the database file is created
|
# Start a dummy activation to ensure the database file is created
|
||||||
client_cmd = [PYTHON3, '-u', 'pykms_Client.py', os.environ.get('IP', "0.0.0.0"), os.environ.get('PORT', 1688),
|
client_cmd = [PYTHON3, '-u', 'pykms_Client.py', listen_ip, listen_port,
|
||||||
'-m', 'Windows10', '-n', 'DummyClient', '-c', 'ae3a27d1-b73a-4734-9878-70c949815218',
|
'-m', 'Windows10', '-n', 'DummyClient', '-c', 'ae3a27d1-b73a-4734-9878-70c949815218',
|
||||||
'-V', os.environ.get('LOGLEVEL', 'INFO'), '-F', os.environ.get('LOGFILE', 'STDOUT')]
|
'-V', log_level, '-F', log_file]
|
||||||
if os.environ.get('LOGSIZE', '') != "":
|
if os.environ.get('LOGSIZE', '') != "":
|
||||||
client_cmd.append('-S')
|
client_cmd.append('-S')
|
||||||
client_cmd.append(os.environ.get('LOGSIZE'))
|
client_cmd.append(os.environ.get('LOGSIZE'))
|
||||||
|
|
||||||
loggersrv.info("Starting a dummy activation to ensure the database file is created")
|
loggersrv.info("Starting a dummy activation to ensure the database file is created")
|
||||||
loggersrv.debug("client_cmd: %s" % (" ".join(str(x) for x in client_cmd).strip()))
|
loggersrv.debug("client_cmd: %s" % (" ".join(str(x) for x in client_cmd).strip()))
|
||||||
|
|
||||||
|
@ -45,7 +48,7 @@ def start_kms_client():
|
||||||
def start_kms():
|
def start_kms():
|
||||||
sqlite_process = None
|
sqlite_process = None
|
||||||
# Build the command to execute
|
# Build the command to execute
|
||||||
command = [PYTHON3, '-u', 'pykms_Server.py', os.environ.get('IP'), os.environ.get('PORT')]
|
command = [PYTHON3, '-u', 'pykms_Server.py', listen_ip, listen_port]
|
||||||
for (arg, env) in argumentVariableMapping.items():
|
for (arg, env) in argumentVariableMapping.items():
|
||||||
if env in os.environ and os.environ.get(env) != '':
|
if env in os.environ and os.environ.get(env) != '':
|
||||||
command.append(arg)
|
command.append(arg)
|
||||||
|
@ -55,6 +58,7 @@ def start_kms():
|
||||||
loggersrv.info("Storing database file to %s" % dbPath)
|
loggersrv.info("Storing database file to %s" % dbPath)
|
||||||
command.append('-s')
|
command.append('-s')
|
||||||
command.append(dbPath)
|
command.append(dbPath)
|
||||||
|
os.makedirs(os.path.dirname(dbPath), exist_ok=True)
|
||||||
|
|
||||||
loggersrv.debug("server_cmd: %s" % (" ".join(str(x) for x in command).strip()))
|
loggersrv.debug("server_cmd: %s" % (" ".join(str(x) for x in command).strip()))
|
||||||
pykms_process = subprocess.Popen(command)
|
pykms_process = subprocess.Popen(command)
|
||||||
|
@ -63,9 +67,8 @@ def start_kms():
|
||||||
if enableSQLITE:
|
if enableSQLITE:
|
||||||
time.sleep(5) # The server may take a while to start
|
time.sleep(5) # The server may take a while to start
|
||||||
start_kms_client()
|
start_kms_client()
|
||||||
sqlite_cmd = [PYTHON3, '-u', '/home/sqlite_web/sqlite_web.py', '-H', os.environ.get('IP'), '--read-only', '-x',
|
sqlite_cmd = [PYTHON3, '-u', '/home/sqlite_web/sqlite_web.py', '-H', listen_ip, '--read-only', '-x',
|
||||||
dbPath,
|
dbPath, '-p', sqlite_port]
|
||||||
'-p', os.environ.get('SQLITE_PORT')]
|
|
||||||
|
|
||||||
loggersrv.debug("sqlite_cmd: %s" % (" ".join(str(x) for x in sqlite_cmd).strip()))
|
loggersrv.debug("sqlite_cmd: %s" % (" ".join(str(x) for x in sqlite_cmd).strip()))
|
||||||
sqlite_process = subprocess.Popen(sqlite_cmd)
|
sqlite_process = subprocess.Popen(sqlite_cmd)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue