Beispiel #1
0
def give_state():
    global maxX, current, step_size
    global fhinished
    global x, z

    temp = False

    with open('data/ids.json', 'r') as f:
        ids = json.load(f)
        f.close()

    if temp == False:
        id = list(ids['ids'])

        highest = max(id)
        id.append(highest + 1)

    seedRange = current + step_size

    if seedRange >= maxX:

        if fhinished > 0:
            log("Complete", request.remote_addr)
            return "done", 123

        fhinished = 1
        seedRange = maxX

    x = {
        "seedMin": current + 1,
        "seedMax": seedRange,
        "x": [1, 3, 4, 5, 1, 3, 2, 9, 10],
        "z": [2, 2, 0, 5, 4, 6, 6, 5, 7],
        "set": highest + 1
        # gives and id to the current set which is later check when done is called and that saves it so can later check if this set is completed
    }

    current = seedRange
    with open('data/ids.json', 'w') as f:
        ids['ids'] = id
        json.dump(ids, f, indent=4)
        f.close()

    return jsonify(x), 200
Beispiel #2
0
def done():
    data2 = request.data.decode()
    data = json.loads(data2)
    log(data, request.remote_addr)
    if data['state'] == True:
        state = True
    else:
        state = False

    with open('data/sets.json', 'r') as f:
        sets = json.load(f)
        f.close()

    sets[data['set']] = state

    with open('data/sets.json', 'w') as f:
        json.dump(sets, f, indent=4)
        f.close()

    return "coolio", 200
Beispiel #3
0
def working_seeds():
    data2 = request.data.decode()
    data = json.loads(data2)
    log(data, request.remote_addr)
    try:

        with open('data/seeds.json', 'r') as f:
            seedFile = json.load(f)
            f.close()
        seedList = list(seedFile['seeds'])

        for i in data['seeds']:
            seedList.append(i)

        with open('data/seeds.json', 'w') as f:
            seedFile['seeds'] = seedList
            json.dump(seedFile, f, indent=4)
            f.close()

        return "cool", 200
    except Exception as e:
        print(e)
        return "error", 400
Beispiel #4
0
def processjson():
    data2 = request.data.decode()
    f = json.loads(data2)
    log(f, request.remote_addr)
    return jsonify(f)
Beispiel #5
0
import json

app = Flask(__name__)

current = 0
step_size = 200000000
maxX = 281474976710656
fhinished = 0

x = [1, 3, 4, 5, 1, 3, 2, 9, 10]
z = [2, 2, 0, 5, 4, 6, 6, 5, 7]

with open('data/ids.json', 'r') as f:
    ids = json.load(f)
    highd = max(ids['ids'])
    log(highd)
    current = highd * step_size
    log(current)
    f.close()

with open('data/sets.json', 'r') as f:
    sets = json.load(f)
    for i in sets:
        state = sets[i]
        if not state:
            log(state)
    f.close()


@app.route("/")
def home():