def fill_payment_order(ucenter, order_id, partner_order_id): info = {} timestamp = int(time.time() * 1000) info["timestamp"] = timestamp info["sign"] = md5mgr.mkmd5fromstr( "%s%s%s%s" % (timestamp, order_id, partner_order_id, "$#@$%%eweqwlkfef")) info["orderNo"] = order_id info["partnerOrderId"] = partner_order_id if ucenter == "android": host = "wapi.android.3qchibi.com" elif ucenter == "wapi" or ucenter == "bapi": host = "wapi.ldsg.tkp.wartown.com.tw" elif ucenter == "ios": host = "wapi.ios.3qchibi.com" url = "http://" + host + ":8088//webApi/fillOrder.do" logging.debug(url) success, ret_val = http_util.request(url, info) logging.debug(ret_val) if success: logging.info(ret_val) result = json.loads(ret_val) return result.get("rc") == 1000
def set_game_web_status(ucenter='android', status=0): white_ip_list = WhiteIp.query(condition="ucenter='%s'" % ucenter) ip_list = [] for white_ip in white_ip_list: ip_list.append(white_ip.ip) info = {} timestamp = int(time.time() * 1000) info["timestamp"] = timestamp info["sign"] = md5mgr.mkmd5fromstr("%s%s" % (timestamp, "gCvKaE0tTcWtHsPkbRdE")) info["status"] = status info["id"] = 5 if ucenter == "android" else 6 info["whiteList"] = ",".join(ip_list) if ucenter == "android": host = "wapi.android.3qchibi.com" elif ucenter == "ios": host = "wapi.ios.3qchibi.com" url = "http://" + host + ":8088//webApi//setServerStatus.do" success, ret_val = http_util.request(url, info) if success: logging.info(ret_val) result = json.loads(ret_val) return result.get("rc") == 1000
def handle(self, file_name): if not file_name.endswith(".sql"): self.log("is not a sql file[%s]" % file_name) return if self.check(file_name) == False: self.log("file had execute[%s]" % file_name) return; info = {} info["file_name"] = file_name info["file_name_md5"] = md5mgr.mkmd5fromstr(file_name) info["start_time"] = datetime.now() status = 1 server = file_name.replace(".sql", "").split("_")[-1] self.log("server[%s]" % server) server_list = self.get_server_list(server); self.log("server list[%s]" % server_list) finish_count = 0 for server_id in server_list: conn = get_connection(db_configs[server_id]) cursor = conn.cursor() start = time.time() sql_list = self.get_sql_list(file_name) cursor.autocommit(True) try: sqls = "" for sql in sql_list: finish_count += 1 sql = sql.strip() if not sql: continue sql = sql.replace("\n", "").replace("\r", "") #self.log("sql[%s]" % sql) sqls += sql if finish_count % self.batch_count == 0: try: cursor.execute(sqls) except OperationalError, e: if e.args[0] not in (1050, 1060): raise sqls = "" self.log("execute[%s]" % finish_count) if sqls: try: cursor.execute(sqls) except OperationalError, e: if e.args[0] != 1006: raise
def handle(self, file_name): if not file_name.endswith(".sql"): self.log("is not a sql file[%s]" % file_name) return if self.check(file_name) == False: self.log("file had execute[%s]" % file_name) return info = {} info["file_name"] = file_name info["file_name_md5"] = md5mgr.mkmd5fromstr(file_name) info["start_time"] = datetime.now() status = 1 server = file_name.replace(".sql", "").split("_")[-1] self.log("server[%s]" % server) server_list = self.get_server_list(server) self.log("server list[%s]" % server_list) finish_count = 0 for server_id in server_list: conn = get_connection(db_configs[server_id]) cursor = conn.cursor() start = time.time() sql_list = self.get_sql_list(file_name) cursor.autocommit(True) try: sqls = "" for sql in sql_list: finish_count += 1 sql = sql.strip() if not sql: continue sql = sql.replace("\n", "").replace("\r", "") # self.log("sql[%s]" % sql) sqls += sql if finish_count % self.batch_count == 0: try: cursor.execute(sqls) except OperationalError, e: if e.args[0] not in (1050, 1060): raise sqls = "" self.log("execute[%s]" % finish_count) if sqls: try: cursor.execute(sqls) except OperationalError, e: if e.args[0] != 1006: raise
def check(self, file_name): conn = get_connection(DB_Mysql) cursor = conn.cursor() file_name_md5 = md5mgr.mkmd5fromstr(file_name) try: info = cursor.fetchone("select 1 from script_execute_log where file_name_md5 = '%s'" % file_name_md5) if info : return False else: return True finally: cursor.close()
def check(self, file_name): conn = get_connection(DB_Mysql) cursor = conn.cursor() file_name_md5 = md5mgr.mkmd5fromstr(file_name) try: info = cursor.fetchone("select 1 from script_execute_log where file_name_md5 = '%s'" % file_name_md5) if info: return False else: return True finally: cursor.close()
def send_notice_to_server(self, server_id, content): info = {} timestamp = int(time.time() * 1000) info["timestamp"] = timestamp info["sign"] = md5mgr.mkmd5fromstr("%s%s%s" % (content, timestamp, "gCvKaE0tTcWtHsPkbRdE")) info["partnerIds"] = "all" info["content"] = content server = server_business.get_server(server_id=server_id) url = "http://" + server.server_host + ":8088//gameApi/sendSysMsg.do" success, ret_val = http_util.request(url, info) if success: result = json.loads(ret_val) return result.get("rt") == 1000
def login(username, password): """""" LOGIN_ERROR = "您输入的用户名或者密码不正确,请重新登录。" if not username or not password: return -1, LOGIN_ERROR #password = md5mgr.mkmd5fromstr(md5mgr.mkmd5fromstr(password)) user = User.load(username=username) if not user or user.password != password: return -1, LOGIN_ERROR if user.status != 0: return -1, "您的帐号已经被停用,请联系管理员" session_id = md5mgr.mkmd5fromstr('%s%s' % (uuid4(), username)) user.session_id = session_id user.persist() return 0, session_id
def fill_payment_order(ucenter, order_id, partner_order_id): info = {} timestamp = int(time.time() * 1000) info["timestamp"] = timestamp info["sign"] = md5mgr.mkmd5fromstr("%s%s%s%s" % (timestamp, order_id, partner_order_id, "$#@$%%eweqwlkfef")) info["orderNo"] = order_id info["partnerOrderId"] = partner_order_id if ucenter == "android": host = "wapi.android.3qchibi.com" elif ucenter == "wapi" or ucenter == "bapi": host = "wapi.ldsg.tkp.wartown.com.tw" elif ucenter == "ios": host = "wapi.ios.3qchibi.com" url = "http://" + host + ":8088//webApi/fillOrder.do" logging.debug(url) success, ret_val = http_util.request(url, info) logging.debug(ret_val) if success: logging.info(ret_val) result = json.loads(ret_val) return result.get("rc") == 1000