コード例 #1
0
ファイル: ncb_server.py プロジェクト: JakubBerlinski/NCB
def sendJSON():
    global recentUpload
    if request.method == 'POST':
        jsonObj = request.get_json(False,False,False)

        print("JSON RECEIVED")

        util.changeAllKeys(jsonObj, u'cellGroups', u'groups')
        util.changeAllKeys(jsonObj, u'cellAliases', u'neuron_aliases')
        util.changeAllKeys(jsonObj, u'name', u'entity_name')
        util.changeAllKeys(jsonObj, u'type', u'entity_type')

        print(json.dumps(jsonObj, indent=4))

        recentUpload = recentUpload.replace(app.config['UPLOAD_FOLDER'] + '/', 'exports/')
        print('Export File: %s' % recentUpload)
        with open(recentUpload, 'w') as fout:
            json.dump(jsonObj, fout, indent=4)

        return jsonify({"success" : True})

    elif request.method == 'GET':
        try:
            print("using file: %s" % recentUpload)
            with open(recentUpload) as fin:
                jsonObj = json.load(fin)

            print("JSON SENT")
            print(jsonObj)
            return jsonify(jsonObj)

        except IOError:
            print("SERVER ERROR: No JSON file to upload!")

    return jsonify({"success" : False})
コード例 #2
0
ファイル: ncb_server.py プロジェクト: mvancompernolle/ncb
def saveJSONFile(fileName, JSON):
    util.changeAllKeys(JSON, u'cellGroups', u'groups')
    util.changeAllKeys(JSON, u'cellAliases', u'neuron_aliases')
    util.changeAllKeys(JSON, u'name', u'entity_name')
    util.changeAllKeys(JSON, u'type', u'entity_type')

    with open(fileName, 'w') as fout:
        json.dump(JSON, fout, indent=4)
コード例 #3
0
ファイル: ncb_server.py プロジェクト: JakubBerlinski/NCB
def saveJSONFile(fileName, JSON):
    util.changeAllKeys(JSON, u'cellGroups', u'groups')
    util.changeAllKeys(JSON, u'cellAliases', u'neuron_aliases')
    util.changeAllKeys(JSON, u'name', u'entity_name')
    util.changeAllKeys(JSON, u'type', u'entity_type')

    with open(fileName, 'w') as fout:
        json.dump(JSON, fout, indent=4)
コード例 #4
0
ファイル: ncb_server.py プロジェクト: mvancompernolle/ncb
def loadJSONFile(fileName):
    try:
        with open(fileName) as fin:
            jsonObj = json.load(fin)

    except IOError:
        print("Error: %s not found." % (fileName, ))
        return {'success': False}

    util.changeAllKeys(jsonObj, u'groups', u'cellGroups')
    util.changeAllKeys(jsonObj, u'neuron_aliases', u'cellAliases')
    util.changeAllKeys(jsonObj, u'entity_name', u'name')
    util.changeAllKeys(jsonObj, u'entity_type', u'type')

    return jsonObj
コード例 #5
0
ファイル: ncb_server.py プロジェクト: JakubBerlinski/NCB
def loadJSONFile(fileName):
    try:
        with open(fileName) as fin:
            jsonObj = json.load(fin)

    except IOError:
        print("Error: %s not found." % (fileName,))
        return {'success': False}

    util.changeAllKeys(jsonObj, u'groups', u'cellGroups')
    util.changeAllKeys(jsonObj, u'neuron_aliases', u'cellAliases')
    util.changeAllKeys(jsonObj, u'entity_name', u'name')
    util.changeAllKeys(jsonObj, u'entity_type', u'type')

    return jsonObj
コード例 #6
0
ファイル: ncb_server.py プロジェクト: mvancompernolle/ncb
def sendJSON():
    global recentUpload
    if request.method == 'POST':
        jsonObj = request.get_json(False, False, False)

        print("JSON RECEIVED")

        util.changeAllKeys(jsonObj, u'cellGroups', u'groups')
        util.changeAllKeys(jsonObj, u'cellAliases', u'neuron_aliases')
        util.changeAllKeys(jsonObj, u'name', u'entity_name')
        util.changeAllKeys(jsonObj, u'type', u'entity_type')

        print(json.dumps(jsonObj, indent=4))

        recentUpload = recentUpload.replace(app.config['UPLOAD_FOLDER'] + '/',
                                            'exports/')
        print('Export File: %s' % recentUpload)
        with open(recentUpload, 'w') as fout:
            json.dump(jsonObj, fout, indent=4)

        return jsonify({"success": True})

    elif request.method == 'GET':
        try:
            print("using file: %s" % recentUpload)
            with open(recentUpload) as fin:
                jsonObj = json.load(fin)

            print("JSON SENT")
            print(jsonObj)
            return jsonify(jsonObj)

        except IOError:
            print("SERVER ERROR: No JSON file to upload!")

    return jsonify({"success": False})