stanley-king 4 years atrás
parent
commit
4f8fff5079
2 changed files with 22 additions and 10 deletions
  1. 21 10
      plot/DataCenter.py
  2. 1 0
      plot/thdf5.py

+ 21 - 10
plot/DataCenter.py

@@ -40,24 +40,35 @@ class DataCenter(object):
         self._mTrdReader.join()
 
     def prepare_data(self):
-        while not self._mquit:
-            try:
-                # pool = redis.ConnectionPool(host='121.89.223.81', port=57649, db=0)
-                pool = redis.ConnectionPool(host='172.26.105.125', port=6379, db=0)
-                r = redis.Redis(connection_pool=pool)
-                self.read_redis(r, 'nc_channel_monitor_commit', 'commit')
-                self.read_redis(r, 'nc_channel_monitor_notify', 'notify')
-                break
-            except Exception as ex:
-                print(ex)
+        try:
+            # pool = redis.ConnectionPool(host='121.89.223.81', port=57649, db=0)
+            pool = redis.ConnectionPool(host='172.26.105.125', port=6379, db=0)
+            r = redis.Redis(connection_pool=pool)
+            self.read_redis(r, 'nc_channel_monitor_commit', 'commit')
+            self.read_redis(r, 'nc_channel_monitor_notify', 'notify')
+        except Exception as ex:
+            print(ex)
+        # while not self._mquit:
+        #     try:
+        #         # pool = redis.ConnectionPool(host='121.89.223.81', port=57649, db=0)
+        #         pool = redis.ConnectionPool(host='172.26.105.125', port=6379, db=0)
+        #         r = redis.Redis(connection_pool=pool)
+        #         self.read_redis(r, 'nc_channel_monitor_commit', 'commit')
+        #         self.read_redis(r, 'nc_channel_monitor_notify', 'notify')
+        #         break
+        #     except Exception as ex:
+        #         print(ex)
             # finally:
             #     time.sleep(60)
         pass
 
     def read_redis(self, redis, name, prefix):
+        i = 0
         for item in redis.hscan_iter(name):
             key = str(item[0], encoding="utf-8")
             val = str(item[1], encoding="utf-8")
+            print(f'{prefix}:{i}')
+            i += 1
             self.parase(key, val, prefix)
 
     def parase(self, text, val, prefix):

+ 1 - 0
plot/thdf5.py

@@ -22,6 +22,7 @@ class DataTest(unittest.TestCase):
         except Exception as ex:
             print(ex)
 
+    #docker-compose run pythoncli python -m unittest thdf5.DataTest.test_predata
     def test_predata(self):
         try:
             data = DataCenter()