summaryrefslogtreecommitdiff
path: root/Code/get_mapped_data.py
diff options
context:
space:
mode:
authorLan Hui <lanhui@zjnu.edu.cn>2025-07-30 18:11:35 +0800
committerLan Hui <lanhui@zjnu.edu.cn>2025-07-30 18:11:35 +0800
commitf6d8fd9133c387a1ec7938e028c1289322cf739e (patch)
tree7e2f5108bd3c2e11897d4f25a07ab2188b3c478c /Code/get_mapped_data.py
parentd1de8f4648f691879619f42af1e3aedaae94c499 (diff)
Use redis to transfer newly mapped data [not tested]
Diffstat (limited to 'Code/get_mapped_data.py')
-rw-r--r--Code/get_mapped_data.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Code/get_mapped_data.py b/Code/get_mapped_data.py
new file mode 100644
index 0000000..d1a4146
--- /dev/null
+++ b/Code/get_mapped_data.py
@@ -0,0 +1,17 @@
+from configure import MAPPED_RDATA_DIR
+from configure import REDIS_CHANNEL
+from log import write_log_file
+import redis # install redis on Ubuntu using this command: sudo apt install python3-redis
+import json
+import os
+
+r = redis.Redis(host='118.25.96.118', port=6379, db=0)
+pubsub = r.pubsub(ignore_subscribe_messages=True)
+pubsub.subscribe(REDIS_CHANNEL)
+
+for message in pubsub.listen():
+ quant_data = json.loads(message['data'])
+ filename = os.path.join(MAPPED_RDATA_DIR, quant_data['filename'])
+ write_log_file('[get_mapped_data.py] Save %s.' % (filename), UPDATE_NETWORK_LOG_FILE))
+ with open(filename, 'w') as f:
+ f.write(quant_data['data'])