Commit 4908426d authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

refactor dfs

parent a625f967
...@@ -5,7 +5,7 @@ from csst_dfs_client import plan, level0 ...@@ -5,7 +5,7 @@ from csst_dfs_client import plan, level0
from astropy.table import Table from astropy.table import Table
import socket import socket
CONFIG = toml.load(os.path.join(os.path.dirname(__file__), "config", "config.toml")) CONFIG = toml.load(os.path.join(os.path.dirname(__file__), "config.toml"))
def check_port(ip, port, timeout=3): def check_port(ip, port, timeout=3):
...@@ -34,10 +34,9 @@ def check_port(ip, port, timeout=3): ...@@ -34,10 +34,9 @@ def check_port(ip, port, timeout=3):
class DFS: class DFS:
def __init__(self, location=None): def __init__(self, location=None):
# try each location # try each location
print("Test all locations:", end="") print("Test all locations...", end="")
status_list = [] status_list = []
for loc in CONFIG.keys(): for loc in CONFIG.keys():
print(f"{loc}...", end="")
dfs_ip = CONFIG[loc]["dfs"]["CSST_DFS_GATEWAY"].split(":")[0] dfs_ip = CONFIG[loc]["dfs"]["CSST_DFS_GATEWAY"].split(":")[0]
dfs_port = int(CONFIG[loc]["dfs"]["CSST_DFS_GATEWAY"].split(":")[1]) dfs_port = int(CONFIG[loc]["dfs"]["CSST_DFS_GATEWAY"].split(":")[1])
redis_ip = CONFIG[loc]["redis"]["host"] redis_ip = CONFIG[loc]["redis"]["host"]
...@@ -55,7 +54,7 @@ class DFS: ...@@ -55,7 +54,7 @@ class DFS:
print("Done!\n") print("Done!\n")
status_table = Table(status_list) status_table = Table(status_list)
print(status_table) print(status_table)
print("\n")
if status_table["status"].sum() == 0: if status_table["status"].sum() == 0:
raise ValueError("No DFS location is available") raise ValueError("No DFS location is available")
elif status_table["status"].sum() > 1: elif status_table["status"].sum() > 1:
......
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