示例#1
0
def upload_file():
    if request.method == 'POST':
        #  file = request.files['file']
        #     if file and allowed_file(file.filename):
        #         filename = secure_filename(file.filename)
        #         file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

        #         ## snippet to read code below
        #         file.stream.seek(0) # seek to the beginning of file
        #         myfile = file.file # will point to tempfile itself
        #         dataframe = pd.read_csv(myfile)
        #         ## end snippet
        user = auth.getLoggedInUser(request.headers['Authorization'])
        # check if the post request has the file part
        file = request.files.get('file')
        # if user does not select file, browser also
        # submit an empty part without filename
        if file.filename == '':
            flash('No file part')
            return exceptionHandler.InvalidUsage('Invalid Recording', status_code=420)
        if file and allowed_file(file.filename) and not mongoConnector.existInDatabase(file.filename):
            filename = uploader._safe_filename(file.filename)
            file.save('./' + filename)
            response = mongoConnector.pushToDatabase(filename, user['email'], user['permission'])
            return mongoConnector.prepareResponse(response)
    return '''
示例#2
0
def upload_file():
    if request.method == 'POST':
        #  file = request.files['file']
        #     if file and allowed_file(file.filename):
        #         filename = secure_filename(file.filename)
        #         file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

        #         ## snippet to read code below
        #         file.stream.seek(0) # seek to the beginning of file
        #         myfile = file.file # will point to tempfile itself
        #         dataframe = pd.read_csv(myfile)
        #         ## end snippet
        user = auth.getLoggedInUser(request.headers['Authorization'])
        # check if the post request has the file part
        file = request.files['file']
        # if user does not select file, browser also
        # submit an empty part without filename
        if file.filename == '':
            flash('No file part')
            return exceptionHandler.InvalidUsage('Invalid Recording', status_code=420)
        if file and allowed_file(file.filename) and not mongo.existInDatabase(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            response = mongo.pushToDatabase(filename, user['email'], user['permission'])
            return mongo.prepareResponse(response)
    return '''
示例#3
0
def getMetaData():
    user = auth.getLoggedInUser(request.headers['Authorization'])
    obj = {
        '$lookup': {
            'from': 'powerFrequency',
            'localField': 'gcsFileUrl',
            'foreignField': 'gcsFileUrl',
            'as': 'recordingsWithPowerData'
        }
    }
    userRecordingsWithPower = routesHandler.recordingsCollection.aggregate(
        [obj])
    uRecords = []
    sRecords = []
    for obj in userRecordingsWithPower:
        if (obj['user'] == user and obj['permission'] == 'guest'):
            uRecords.append(obj)
        if (obj['permission'] == 'administrator'):
            sRecords.append(obj)

    latestComparison = routesHandler.comparisonCollection.find(
        {'user.email': user['email']})
    metaData = {
        'userRecordings': uRecords,
        'sampleRecordings': sRecords,
        'latestComparison': latestComparison
    }
    return prepareResponse(metaData)
示例#4
0
def getMetaData():
    user = auth.getLoggedInUser(request.headers['Authorization'])
    obj = {
            '$lookup':
                {
                    'from': 'powerFrequency',
                    'localField': 'stereoFilePath',
                    'foreignField': 'stereoFilePath',
                    'as': 'recordingsWithPowerData'
                }
            }
    userRecordingsWithPower = routes.recordingsCollection.aggregate([obj])
    uRecords = []
    sRecords = []
    for obj in userRecordingsWithPower:
        if (obj['user'] == user and obj['permission'] == 'guest'):
            uRecords.append(obj)
        if (obj['permission'] == 'administrator'):
            sRecords.append(obj)

    latestComparison = routes.comparisonCollection.find({'user': user})
    metaData = {
        'userRecordings': uRecords,
        'sampleRecordings': sRecords,
        'latestComparison': latestComparison
    }
    return prepareResponse(metaData)
示例#5
0
def getMyUserAudioFiles():
    user = auth.getLoggedInUser(request.headers['Authorization'])
    return retrieveData.retrieveMyRecordings(user['email'])
示例#6
0
def getUserAudioFiles():
    user = auth.getLoggedInUser(request.headers['Authorization'])
    print(user['email'])
    return mongoConnector.retrieve(user['email'])
示例#7
0
def getMyUserAudioFiles():
    user = auth.getLoggedInUser(request.headers['Authorization'])
    return retrieveData.retrieveMyRecordings(user['email'])
示例#8
0
def getUserAudioFiles():
    user = auth.getLoggedInUser(request.headers['Authorization'])
    print(user['email'])
    return mongo.retrieve(user['email'])