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

refactor dfs

parent a625f967
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ from csst_dfs_client import plan, level0
from astropy.table import Table
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):
@@ -34,10 +34,9 @@ def check_port(ip, port, timeout=3):
class DFS:
    def __init__(self, location=None):
        # try each location
        print("Test all locations:", end="")
        print("Test all locations...", end="")
        status_list = []
        for loc in CONFIG.keys():
            print(f"{loc}...", end="")
            dfs_ip = CONFIG[loc]["dfs"]["CSST_DFS_GATEWAY"].split(":")[0]
            dfs_port = int(CONFIG[loc]["dfs"]["CSST_DFS_GATEWAY"].split(":")[1])
            redis_ip = CONFIG[loc]["redis"]["host"]
@@ -55,7 +54,7 @@ class DFS:
        print("Done!\n")
        status_table = Table(status_list)
        print(status_table)

        print("\n")
        if status_table["status"].sum() == 0:
            raise ValueError("No DFS location is available")
        elif status_table["status"].sum() > 1: