|
|
@@ -3,6 +3,7 @@
|
|
|
import sqlite3
|
|
|
import json
|
|
|
import sys
|
|
|
+import os
|
|
|
|
|
|
"""
|
|
|
Reads the API KEY, that must be passed as first command line argument.
|
|
|
@@ -27,7 +28,7 @@ Reads the JSON data, that must be passed as second command line argument.
|
|
|
"""
|
|
|
def readData():
|
|
|
try:
|
|
|
- #print(sys.argv[1])
|
|
|
+ print(sys.argv[2])
|
|
|
data = json.loads(sys.argv[2])
|
|
|
return data
|
|
|
except Exception as e:
|
|
|
@@ -48,7 +49,7 @@ def verifyKey(db, data, key):
|
|
|
print('Verifying KEY...')
|
|
|
status = False
|
|
|
try:
|
|
|
- uid = data["wizard_info"]["wizard_id"]
|
|
|
+ uid = data["uid"]
|
|
|
cursor = db.cursor()
|
|
|
cursor.execute('SELECT count(uid) AS c FROM player WHERE uid = ? AND api_key = ?;', (uid, key))
|
|
|
if cursor.fetchone()[0] == 1:
|
|
|
@@ -128,6 +129,8 @@ def parseRun(db, data):
|
|
|
helper = data["helper"]
|
|
|
cursor.execute("SELECT max(id) + 1 AS id FROM run;")
|
|
|
id = cursor.fetchone()[0]
|
|
|
+ if id == None:
|
|
|
+ id = 1
|
|
|
insert(db, "run", (uid, id, dtime, area, stage, difficulty, win, time, mana, energy, crystal, helper))
|
|
|
if data["shapeshifting"] > 0:
|
|
|
insert(db, "run_drop_shapeshifting", (id, data["shapeshifting"]))
|
|
|
@@ -175,13 +178,13 @@ def parseRun(db, data):
|
|
|
Begin script
|
|
|
"""
|
|
|
data = readData()
|
|
|
-data = readKey()
|
|
|
-db = openDatabase('../../../../application/sw.sqlite')
|
|
|
+key = readKey()
|
|
|
+db = openDatabase(os.path.dirname(os.path.realpath(sys.argv[0])) + '/../sw.sqlite')
|
|
|
if verifyKey(db, data, key) == False:
|
|
|
print("Invalid API KEY...")
|
|
|
- return -1
|
|
|
+ sys.exit(-1)
|
|
|
else:
|
|
|
parseRun(db, data)
|
|
|
-return 0
|
|
|
+sys.exit(0)
|
|
|
|
|
|
|