From affca29e7500fc8e2e65cf15d19496a370f6329e Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 27 十二月 2018 16:22:58 +0800
Subject: [PATCH] 860312 机器人

---
 Tool/RobotTest/framework/frame.py |   85 +++++++++++++++++++++++-------------------
 1 files changed, 47 insertions(+), 38 deletions(-)

diff --git a/Tool/RobotTest/framework/frame.py b/Tool/RobotTest/framework/frame.py
index 7ee4cae..1366547 100644
--- a/Tool/RobotTest/framework/frame.py
+++ b/Tool/RobotTest/framework/frame.py
@@ -27,7 +27,7 @@
 
 import traceback
 import base64
-#import pymongo
+import pymongo
 import datetime
 
 
@@ -83,50 +83,54 @@
         
         self.PlayerOffTime = config.GetPlayerOffTime() #玩家下线时长
         self.ServerDBConfigPath = config.GetServerDBConfigPath()    #数据库路径
-        #self.InitDBCon()
+        self.InitDBCon()
         
         self.tokenList = []   # 数据库获取,登录去除
-        self.maxPlayerCnt = 200
+        self.maxPlayerCnt = config.GetMaxPlayerCnt()
         self.loginCnt = 0
-    #===========================================================================
-    # def InitDBCon(self):
-    #    dbConfig = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath1)
-    #    dbConfig.SetSection( "auth" )
-    #    self.user = dbConfig.GetValue("logdb_user")
-    #    self.pwd = GetEncodePsw(dbConfig.GetValue("logdb_pwd"))[1]
-    #    
-    #    dbConfig2 = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath2)
-    #    dbConfig2.SetSection( "connect" )
-    #    self.dbIP = dbConfig2.GetValue("LOG_DB_IP")
-    #    self.connection = pymongo.Connection(self.dbIP, 27017, auto_start_request=False)
-    #    db = self.connection.admin
-    #    if not db.authenticate(self.user, self.pwd):
-    #        logging.error( "!!!InitDBCon error" )
-    #        return
-    #    
-    #    #print dbConfig2.GetValue("LOG_DB_NAME"), "--------------"
-    #    
-    #    self.logdb = self.connection[dbConfig2.GetValue("LOG_DB_NAME")]
-    #    #self.interfaceDatadb = self.connection[dbConfig2.GetValue("INTERFACE_DB_NAME")]
-    #    self.userdb = self.connection[dbConfig2.GetValue("USER_DB_NAME")]
-    #    
-    #    logging.info("conn ok-----------")
-    #===========================================================================
+        self.AccountSource = config.GetAccountSource()
+        
+    def InitDBCon(self):
+        dbConfig = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath1)
+        dbConfig.SetSection( "auth" )
+        self.user = dbConfig.GetValue("userdb_user")
+        self.pwd = GetEncodePsw(dbConfig.GetValue("userdb_pwd"))[1]
+        
+        dbConfig2 = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath2)
+        dbConfig2.SetSection( "connect" )
+        self.dbIP = dbConfig2.GetValue("USER_DB_IP")
+        self.connection = pymongo.Connection(self.dbIP, 27017, auto_start_request=False)
+        db = self.connection.admin
+        if not db.authenticate(self.user, self.pwd):
+            logging.error( "!!!InitDBCon error" )
+            return
+        
+        self.userdb = self.connection[dbConfig2.GetValue("USER_DB_NAME")]
+        
+        logging.info("conn ok-----------")
         
     # 1.获取脱机挂玩家数据--GameLog
     def GetTJGRobot(self):
-        index = 0
-        if len(sys.argv) == 2:
-            index = sys.argv[1]
-        clientMac = "abc"
-        for i in xrange(self.maxPlayerCnt):
-            accID = "ice%s_%s@yun@s1"%(index, i)
-
-            account = ("123456789012345678901234567890ab", accID, clientMac, 1)
-            if account not in self.tokenList:
-                self.tokenList.append(account)
+        if self.AccountSource == 0:
+            index = 0
+            if len(sys.argv) == 2:
+                index = sys.argv[1]
+            clientMac = "abc"
+            for i in xrange(self.maxPlayerCnt):
+                accID = "ice%s_%s@yun@s1"%(index, i)
+    
+                account = ("123456789012345678901234567890ab", accID, clientMac, 1)
+                if account not in self.tokenList:
+                    self.tokenList.append(account)
+        else:
+            col = self.userdb["tagDSAccount"]
+            account = None
+            for rec in col.find(limit=self.maxPlayerCnt):
+                account = ("123456789012345678901234567890ab", str(rec['ACCID']), 'anc', 1)
+                if account not in self.tokenList:
+                    self.tokenList.append(account)
             
-            
+            print account
         if self.tokenList:
             logging.info( "待登录的脱机挂玩家----:%s"%(len(self.tokenList)))
             #logging.debug( "待登录的脱机挂玩家----tokenList:%s"%(self.tokenList))
@@ -136,6 +140,11 @@
     def GetTokenList(self):
         return self.tokenList
     
+    def AddCrossRobotInfo(self, accID, IPList):
+        account = ("123456789012345678901234567890ab", accID, "abc", 1, IPList)
+        if account not in self.tokenList:
+            self.tokenList.append(account)
+    
     def RemoveToken(self, value):
         self.tokenList.remove(value)
     

--
Gitblit v1.8.0