Commit d7b79743 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

update dfs

parent 85880de1
......@@ -3,6 +3,7 @@ import toml
import os
from astropy.table import Table
import socket
from csst_dfs_client import plan, level0, level1, level2, dag, catalog
CONFIG = toml.load(os.path.join(os.path.dirname(__file__), "config.toml"))
......@@ -31,6 +32,14 @@ def check_port(ip, port, timeout=3):
class DFS:
plan = plan
level0 = level0
level1 = level1
level2 = level2
dag = dag
catalog = catalog
def __init__(self, location=None):
# try each location
print("Test all locations...", end="")
......@@ -78,40 +87,41 @@ class DFS:
# self.redis = Redis(location=self.location)
class Redis(redis.Redis):
def __init__(self, location="naoc", **kwargs):
if location not in CONFIG.keys():
print("Available redis locations: ", list(CONFIG.keys()))
raise ValueError(f"Unknown redis location: {location}")
super().__init__(
host=CONFIG[location]["redis"]["host"],
port=CONFIG[location]["redis"]["port"],
db=CONFIG[location]["redis"]["db"],
password=CONFIG[location]["redis"]["password"],
**kwargs,
)
self.qname = password = CONFIG[location]["redis"]["qname"]
self.config = CONFIG[location]["redis"]
# print("Setting redis config:")
# for k, v in self.config.items():
# print(f" - {k}: {v}")
def push(self, msg):
self.lpush(self.qname, msg)
def pop(self):
return self.rpop(self.qname)
dfs = DFS(location=None)
def get_all(self):
return self.lrange(self.qname, 0, -1)
# class Redis(redis.Redis):
# def __init__(self, location="naoc", **kwargs):
# if location not in CONFIG.keys():
# print("Available redis locations: ", list(CONFIG.keys()))
# raise ValueError(f"Unknown redis location: {location}")
# super().__init__(
# host=CONFIG[location]["redis"]["host"],
# port=CONFIG[location]["redis"]["port"],
# db=CONFIG[location]["redis"]["db"],
# password=CONFIG[location]["redis"]["password"],
# **kwargs,
# )
# self.qname = password = CONFIG[location]["redis"]["qname"]
# self.config = CONFIG[location]["redis"]
# # print("Setting redis config:")
# # for k, v in self.config.items():
# # print(f" - {k}: {v}")
#
# def push(self, msg):
# self.lpush(self.qname, msg)
#
# def pop(self):
# return self.rpop(self.qname)
#
# def get_all(self):
# return self.lrange(self.qname, 0, -1)
dfs = DFS(location=None)
# msgs = r.lrange(name, 0, -1)
# for chipid in range(6, 26):
# this_msg = gen_msg(
# dag="csst-msc-l1-mbi", obsid="11009101682009", chipid=f"{chipid:02d}"
# dag_cfg="csst-msc-l1-mbi", obsid="11009101682009", chipid=f"{chipid:02d}"
# )
# print(this_msg)
# r.lpush(name, this_msg)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment