]> gitweb.michael.orlitzky.com - untangle-https-backup.git/commitdiff
bin/untangle-https-backup: expect and report socket timeouts.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 18 Apr 2018 00:38:31 +0000 (20:38 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 18 Apr 2018 00:45:56 +0000 (20:45 -0400)
In the last commit, a configurable socket "timeout" was added. If that
timeout is reached, a socket.timeout exception will be thrown. This
commit catches those exceptions in the main executable, reports them
gracefully, and proceeds with the remaining backups.

bin/untangle-https-backup

index 1f6a2db3fcf671c27176aeff71d01f0fd52912cd..25fbf9d2364a7b94242a3f9b540b8589f658c3f6 100755 (executable)
@@ -8,6 +8,7 @@ import configparser
 from http.client import HTTPException
 from os import chmod
 from urllib.error import HTTPError, URLError
+from socket import timeout
 from sys import stderr
 
 from untangle.untangle import Untangle
@@ -71,5 +72,12 @@ for section in config.sections():
         msg = tpl.format(u.name, repr(e), u.host)
         print(msg, file=stderr)
         status = EXIT_BACKUPS_FAILED
+    except timeout as e:
+        # A socket.timeout exception occurs when something goes over
+        # the configured "timeout" limit.
+        tpl = '{:s}: socket timeout ({:s}) from {:s}'
+        msg = tpl.format(u.name, str(e), u.host)
+        print(msg, file=stderr)
+        status = EXIT_BACKUPS_FAILED
 
 exit(status)