# -*- coding: utf-8 -*- import KBEngine from KBEDebug import * import random import math import time import const import switch from socket import * import base64 http_ip = const.HTTP_SERVER_IP if KBEngine.publish() == 0: http_ip = const.HTTP_DEBUG_SERVER_IP else: http_ip = gethostbyname(http_ip) INFO_MSG("HTTP_SERVER_IP: :%s." % (http_ip)) class SimpleHttpClient(object): def __init__(self): self.udpClient = socket(AF_INET, SOCK_DGRAM) def sendTcpHttpLog(self, operation, json_dict): value = str(json_dict) value = value.replace(' ', '%20') value = value.replace('#', '栋') #value = base64.encodestring(value) sendStr = "GET /log_get_reward.php?key=" + operation + "&value=" + value + " HTTP/1.1\r\nHost: " + http_ip + "\r\nConnection: Close\r\n\r\n" tcpClient = socket(AF_INET, SOCK_STREAM)
def INFO_MSG(*args): if KBEngine.publish() <= 1: KBEngine.scriptLogType(KBEngine.LOG_TYPE_INFO) printMsg(args, False)
def DEBUG_MSG(*args): if KBEngine.publish() == 0: KBEngine.scriptLogType(KBEngine.LOG_TYPE_DBG) printMsg(args, True)
def canExecuteInnerCommand(self): return not KBEngine.publish()
def DEBUG_MSG(*args): if KBEngine.publish() == 0: printMsg("Debug:", args, True)