示例#1
0
文件: logger.py 项目: cwarwar/logger
def parse():
    f = request.files['file']
    if allowed_extensions(f.filename):
        filename = secure_filename(f.filename)
        f.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        response = Log.process(app.config['UPLOAD_FOLDER'] + "/" + f.filename)
        success = True
    else:
        response = 'Invalid extension'
        success = False

    return formatResponse(response, success)
示例#2
0
 def testInsertLogSuccess(self):
     Dal = Mongo(self.log.collectionName)
     Log = self.log(Dal)
     self.assertEqual(len(str(Log.process('/app/fileToSend/log.txt'))), 24)
示例#3
0
 def testInsertLogFail(self):
     Dal = Mongo(self.log.collectionName)
     Log = self.log(Dal)
     with self.assertRaises(OSError):
         Log.process('/app/fileToSend/arquivoinexistente.txt')