X-Git-Url: https://gitweb.michael.orlitzky.com/?p=untangle-https-backup.git;a=blobdiff_plain;f=bin%2Funtangle-https-backup;fp=bin%2Funtangle-https-backup;h=69e46ba0c6af76de91f61a8db725c7df4b25fd26;hp=dab5c1807bb8e9c712c34d0a184df270f93a15e9;hb=e902576de37fc1d86edb35d852b3149fde55213e;hpb=b3244aebc7b201d1b216b1879882e3e618c974a9 diff --git a/bin/untangle-https-backup b/bin/untangle-https-backup index dab5c18..69e46ba 100755 --- a/bin/untangle-https-backup +++ b/bin/untangle-https-backup @@ -5,6 +5,7 @@ Back up Untangle configurations via the web admin UI. from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser import configparser +from http.client import HTTPException from os import chmod from urllib.error import HTTPError, URLError from sys import stderr @@ -51,13 +52,22 @@ for section in config.sections(): chmod(filename, 0o600) # If it didn't work, but in a predictable way (some host is down), - # then we report that error and keep going. + # then we report that error and keep going. At least one sort of + # HTTPException (BadStatusLine) is not translated by urllib into + # an HTTPError, so we catch HTTPExceptions too. except URLError as e: - msg = u.name + ': ' + str(e.reason) + ' from ' + u.host + tpl = '{:s}: {:s} from {:s}' + msg = tpl.format(u.name, str(e.reason), u.host) print(msg, file=stderr) status = EXIT_BACKUPS_FAILED except HTTPError as e: - msg = u.name + ': ' + 'HTTP error ' + str(e.code) + ' from ' + u.host + tpl = '{:s}: HTTP error {:s} from {:s}' + msg = tpl.format(u.name, str(e.code), u.host) + print(msg, file=stderr) + status = EXIT_BACKUPS_FAILED + except HTTPException as e: + tpl = '{:s}: HTTP exception {:s} from {:s}' + msg = tpl.format(u.name, repr(e), u.host) print(msg, file=stderr) status = EXIT_BACKUPS_FAILED