mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
cosmetic: only print hostname warning once
This commit is contained in:
parent
a5ce1032d3
commit
0527b59180
|
@ -204,7 +204,7 @@ def init_E(EE: EnvParams) -> None:
|
||||||
errs.append("Using [%s] instead" % (p,))
|
errs.append("Using [%s] instead" % (p,))
|
||||||
|
|
||||||
if errs:
|
if errs:
|
||||||
print("WARNING: " + ". ".join(errs))
|
warn(". ".join(errs))
|
||||||
|
|
||||||
return p # type: ignore
|
return p # type: ignore
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
@ -234,7 +234,7 @@ def init_E(EE: EnvParams) -> None:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def get_srvname() -> str:
|
def get_srvname(verbose) -> str:
|
||||||
try:
|
try:
|
||||||
ret: str = unicode(socket.gethostname()).split(".")[0]
|
ret: str = unicode(socket.gethostname()).split(".")[0]
|
||||||
except:
|
except:
|
||||||
|
@ -244,7 +244,8 @@ def get_srvname() -> str:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
fp = os.path.join(E.cfg, "name.txt")
|
fp = os.path.join(E.cfg, "name.txt")
|
||||||
lprint("using hostname from {}\n".format(fp))
|
if verbose:
|
||||||
|
lprint("using hostname from {}\n".format(fp))
|
||||||
try:
|
try:
|
||||||
with open(fp, "rb") as f:
|
with open(fp, "rb") as f:
|
||||||
ret = f.read().decode("utf-8", "replace").strip()
|
ret = f.read().decode("utf-8", "replace").strip()
|
||||||
|
@ -1472,7 +1473,7 @@ def add_debug(ap):
|
||||||
|
|
||||||
|
|
||||||
def run_argparse(
|
def run_argparse(
|
||||||
argv: list[str], formatter: Any, retry: bool, nc: int
|
argv: list[str], formatter: Any, retry: bool, nc: int, verbose=True
|
||||||
) -> argparse.Namespace:
|
) -> argparse.Namespace:
|
||||||
ap = argparse.ArgumentParser(
|
ap = argparse.ArgumentParser(
|
||||||
formatter_class=formatter,
|
formatter_class=formatter,
|
||||||
|
@ -1494,7 +1495,7 @@ def run_argparse(
|
||||||
|
|
||||||
tty = os.environ.get("TERM", "").lower() == "linux"
|
tty = os.environ.get("TERM", "").lower() == "linux"
|
||||||
|
|
||||||
srvname = get_srvname()
|
srvname = get_srvname(verbose)
|
||||||
|
|
||||||
add_general(ap, nc, srvname)
|
add_general(ap, nc, srvname)
|
||||||
add_network(ap)
|
add_network(ap)
|
||||||
|
@ -1674,7 +1675,7 @@ def main(argv: Optional[list[str]] = None, rsrc: Optional[str] = None) -> None:
|
||||||
for fmtr in [RiceFormatter, RiceFormatter, Dodge11874, BasicDodge11874]:
|
for fmtr in [RiceFormatter, RiceFormatter, Dodge11874, BasicDodge11874]:
|
||||||
try:
|
try:
|
||||||
al = run_argparse(argv, fmtr, retry, nc)
|
al = run_argparse(argv, fmtr, retry, nc)
|
||||||
dal = run_argparse([], fmtr, retry, nc)
|
dal = run_argparse([], fmtr, retry, nc, False)
|
||||||
break
|
break
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in a new issue