# possible statuses (according to the source here: https://github.com/haiwen/seafile/blob/91e5d897395c728a1e862dbdaf3d8a519c2ed73e/daemon/sync-mgr.c#L471)
# ranked in order from least to most severe in terms of "being synced"
STATUS_RANK = [
"synchronized",
"committing",
"initializing",
"downloading",
"merging",
"uploading",
"error",
"canceled",
"cancel pending",
]
def get_conf_dir():
try:
conf_dir = os.environ["CCNET_CONF_DIR"]
return ["-c", conf_dir]
except KeyError:
return []
def collapse_statuses(xs):
try:
return STATUS_RANK[max(STATUS_RANK.index(x) for x in xs)]
except ValueError:
return "unknown"
def query_statuses():
args = get_conf_dir()
res = sp.run(CMD + args, capture_output=True, check=True)
raw = res.stdout.rstrip().split(b"\n")[1:]
statuses = [ln.split(b"\t")[1].strip().decode() for ln in raw]