<commit_before># -*- encoding:utf-8 -*-
import logging
import os
import sys
from analyzer.StaticInfoPredictor import staticinfo_predict
from analyzer import AppDict
from config import token_config
from package_leancloud_utils.leancloud_utils import LeancloudUtils
import logentries

__author__ = 'Jayvee'

from flask import Flask, request
import json

project_path = os.path.dirname(__file__)
sys.path.append(project_path)
# TODO setup logentries
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logger.addHandler(logentries.LogentriesHandler(token_config.LOGENTRIES_TOKEN))
app = Flask(__name__)


@app.before_first_request
def initService():
    print token_config.APP_ENV
    # logger.info('test')
    # pass


@app.route('/static_info/data', methods=['GET', 'POST'])
def get_applist_data():
    if request.method == 'GET':
        appdict = AppDict.AppDict()
        try:
            if 'limit' in request.args:
                dd = request.args['limit']
                limit_num = int(dd)
            else:
                limit_num = 100
            if 'label' in request.args:
                label = request.args['label']
            else:
                label = None
        except KeyError:
            # TODO setup logentries
            logger.info('keyerror')
            limit_num = 100  # default:limit_num=100
            label = None
        result_list = LeancloudUtils.get_remote_data(appdict, 'AppDict', limit_num, label)
        return json.dumps(result_list)
    # TODO add post method
    # TODO POST method for adding applist data
    return 'You Request Method is Not Correct!'


@app.route('/static_info/predict', methods=['POST'])
def predict_static_info():
    # params JSON validate
    req_data = {}
    try:
        req_data = json.loads(request.data)
    except ValueError, err_msg:
        # TODO setup logentries
        # logger.error('[ValueError] err_msg: %s, params=%s' % (err_msg, request.data))
        pass
    apps = req_data.get('app_list')

    if not apps:
        return '{"error":"param error:no app_list"}'
    # applist = apps.split(',')
    return json.dumps(staticinfo_predict(apps, True, True))


if __name__ == "__main__":
    app.debug = False
    app.run(port=8080)<commit_msg>try logentries in Jenkins<commit_after># -*- encoding:utf-8 -*-
import logging
import os
import sys
from analyzer.StaticInfoPredictor import staticinfo_predict
from analyzer import AppDict
from config import token_config
from package_leancloud_utils.leancloud_utils import LeancloudUtils
import logentries

__author__ = 'Jayvee'

from flask import Flask, request
import json

project_path = os.path.dirname(__file__)
sys.path.append(project_path)
# TODO setup logentries
logger = logging.getLogger('logentries')
logger.setLevel(logging.INFO)
logger.addHandler(logentries.LogentriesHandler(token_config.LOGENTRIES_TOKEN))
app = Flask(__name__)


@app.before_first_request
def initService():
    print token_config.APP_ENV
    logger.info('test')
    # pass


@app.route('/static_info/data', methods=['GET', 'POST'])
def get_applist_data():
    if request.method == 'GET':
        appdict = AppDict.AppDict()
        try:
            if 'limit' in request.args:
                dd = request.args['limit']
                limit_num = int(dd)
            else:
                limit_num = 100
            if 'label' in request.args:
                label = request.args['label']
            else:
                label = None
        except KeyError:
            # TODO setup logentries
            logger.info('keyerror')
            limit_num = 100  # default:limit_num=100
            label = None
        result_list = LeancloudUtils.get_remote_data(appdict, 'AppDict', limit_num, label)
        return json.dumps(result_list)
    # TODO add post method
    # TODO POST method for adding applist data
    return 'You Request Method is Not Correct!'


@app.route('/static_info/predict', methods=['POST'])
def predict_static_info():
    # params JSON validate
    req_data = {}
    try:
        req_data = json.loads(request.data)
    except ValueError, err_msg:
        # TODO setup logentries
        # logger.error('[ValueError] err_msg: %s, params=%s' % (err_msg, request.data))
        pass
    apps = req_data.get('app_list')

    if not apps:
        return '{"error":"param error:no app_list"}'
    # applist = apps.split(',')
    return json.dumps(staticinfo_predict(apps, True, True))


if __name__ == "__main__":
    app.debug = False
    app.run(port=8080)
{'fraction_non_alphanumeric': 0.10513501549358123, 'fraction_numerical': 0.00619743249225321, 'mean_word_length': 2.8789699570815452, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '990165', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1335, 'n_words': 334}