From a84c583b2cfcb3f33ebc83c253948658948af33a Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 27 Apr 2023 19:06:35 +0000 Subject: [PATCH] ok that wasn't enough --- bin/up2k.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/up2k.py b/bin/up2k.py index bdba5134..15447715 100755 --- a/bin/up2k.py +++ b/bin/up2k.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from __future__ import print_function, unicode_literals -S_VERSION = "1.7" -S_BUILD_DT = "2023-04-26" +S_VERSION = "1.8" +S_BUILD_DT = "2023-04-27" """ up2k.py: upload to copyparty @@ -348,6 +348,8 @@ def undns(url): try: gai = socket.getaddrinfo(hn, None) hn = gai[0][4][0] + except KeyboardInterrupt: + raise except: t = "\n\033[31mfailed to resolve upload destination host;\033[0m\ngai={0}\n" eprint(t.format(repr(gai))) @@ -1100,7 +1102,7 @@ source file/folder selection uses rsync syntax, meaning that: ap = app.add_argument_group("compatibility") ap.add_argument("--cls", action="store_true", help="clear screen before start") - ap.add_argument("--rh", action="store_true", help="resolve server hostname before upload (good for buggy networks, but TLS certs will break)") + ap.add_argument("--rh", type=int, metavar="TRIES", default=0, help="resolve server hostname before upload (good for buggy networks, but TLS certs will break)") ap = app.add_argument_group("folder sync") ap.add_argument("--dl", action="store_true", help="delete local files after uploading") @@ -1157,8 +1159,15 @@ source file/folder selection uses rsync syntax, meaning that: with open(fn, "rb") as f: ar.a = f.read().decode("utf-8").strip() - if ar.rh: - ar.url = undns(ar.url) + for n in range(ar.rh): + try: + ar.url = undns(ar.url) + break + except KeyboardInterrupt: + raise + except: + if n > ar.rh - 2: + raise if ar.cls: eprint("\x1b\x5b\x48\x1b\x5b\x32\x4a\x1b\x5b\x33\x4a", end="")