예제 #1
0
파일: views.py 프로젝트: tiger8888/webUI-4
def refresh_table_content():
    #     try:
    #         print request.get_json(), request.get_json(force=True)
    #     except:
    #         print 'f**k you'
    #     print zip(range(5),(request.form, request.args, request.values, request.data, request.json))
    indata = unicode2str(
        {key: dict(request.form)[key][0]
         for key in dict(request.form)})
    print 'injson = ', indata['data']
    return jsonify(ret='success')
예제 #2
0
def update_exit_rule_data():
    global keys
    indata_json = {
        key: dict(request.form)[key][0]
        for key in dict(request.form)
    }['data']
    indata = unicode2str(json.loads(indata_json))
    session['exit_conditions'] = {}
    session['exit_conditions']['exit_nconds'] = len(indata)
    for i, exit_obj in enumerate(indata):
        #         print i,exit_obj
        session['exit_conditions'][str(i)] = [
            exit_obj[_field] for _field in keys
        ]
    return jsonify(success=1)
예제 #3
0
 def recv_back(self):
     while True:
         recv_obj = unicode2str(self.recv_socket.recv_json())
         print 'recv reply = ', recv_obj
         try:
             status = recv_obj['status']
             cmd = recv_obj['key']
             ret = recv_obj['ret']
         except:
             continue
         if status:
             redis_key = self.redis_api.get_key(cmd['date'],
                                                cmd['username'], cmd['pid'],
                                                cmd['requestID'],
                                                cmd['funcName'])
             self.redis_api.set_value(redis_key, ret=recv_obj['ret'])
예제 #4
0
    def recv_cmd(self):
        while True:
            cmd = unicode2str(self.recv_socket.recv_json())
            argkws = cmd['paras']
            if (cmd is not None) and (cmd['funcName'] in self.callbacks):
                print 'args = ', cmd['paras']
                ret = self.callbacks[cmd['funcName']](**argkws)
                print 'ret = ', ret
                key = {k: v for k, v in cmd.iteritems() if k != 'paras'}
                send_pyobj = {'key': key, 'ret': ret, 'status': ret == 0}

                redis_key = self.redis_api.get_key(cmd['date'],
                                                   cmd['username'], cmd['pid'],
                                                   cmd['requestID'],
                                                   cmd['funcName'])
                self.redis_api.set_value(redis_key, ret=ret)

                self.send_socket.send_json(send_pyobj)
                print 'send to web = ', send_pyobj