<commit_before>#-*- coding: utf-8 -*-
import json
import flask
from flask import abort, request as req

from optparse import OptionParser
from remote_manager import RemoteControl, PrepareVMManager, GetAllSystemInfo
from system_control_cmd import *
from VMDash_cli import KEEP_STATISTICS

import time, threading

VMDash = flask.Flask(__name__)

ServerCurrentStatistics = {}

@VMDash.route('/messages', methods = ['POST'])
def get_messages():
    global ServerCurrentStatistics

    if flask.request.headers['Content-Type'] == 'application/json':
        jsonData = flask.request.json
        ServerIPAddr = jsonData['myipaddr']
        ServerCurrentStatistics[ServerIPAddr].append(jsonData)
        if len(ServerCurrentStatistics[ServerIPAddr]) > KEEP_STATISTICS:
            del ServerCurrentStatistics[ServerIPAddr][0]

        return ''

    return '415 Unsupport File'
<commit_msg>add key check for dict<commit_after>#-*- coding: utf-8 -*-
import json
import flask
from flask import abort, request as req

from optparse import OptionParser
from remote_manager import RemoteControl, PrepareVMManager, GetAllSystemInfo
from system_control_cmd import *
from VMDash_cli import KEEP_STATISTICS

import time, threading

VMDash = flask.Flask(__name__)

ServerCurrentStatistics = {}

@VMDash.route('/messages', methods = ['POST'])
def get_messages():
    global ServerCurrentStatistics

    if flask.request.headers['Content-Type'] == 'application/json':
        jsonData = flask.request.json
        ServerIPAddr = jsonData['myipaddr']
        if not ServerCurrentStatistics.has_key(ServerIPAddr):
            ServerCurrentStatistics[ServerIPAddr] = []
        ServerCurrentStatistics[ServerIPAddr].append(jsonData)
        if len(ServerCurrentStatistics[ServerIPAddr]) > KEEP_STATISTICS:
            del ServerCurrentStatistics[ServerIPAddr][0]

        return ''

    return '415 Unsupport File'

{'fraction_non_alphanumeric': 0.08922914466737064, 'fraction_numerical': 0.005279831045406547, 'mean_word_length': 4.3835227272727275, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7261715', 'n_tokens_mistral': 539, 'n_tokens_neox': 514, 'n_words': 132}