aboutsummaryrefslogtreecommitdiff
path: root/git-arr
diff options
context:
space:
mode:
authorAlberto Bertogli <albertito@blitiri.com.ar>2013-11-03 00:32:43 +0100
committerAlberto Bertogli <albertito@blitiri.com.ar>2013-11-03 00:32:43 +0100
commitf6a75820e812f1ab44545cf01f4c475952df0821 (patch)
tree19b37bb461ff7500b8e0c93af09f8da230fe4592 /git-arr
parente49c69da2e53c8938f4d58bd478bb68f060e3849 (diff)
downloadgit-arr-fork-f6a75820e812f1ab44545cf01f4c475952df0821.zip
Work around HTTPError status code issues
It turned out that bottle.py is not backwards-compatible with the status code change: older versions encode the status in e.status; newer ones use e.status_code (and e.status became a string). This patch works around that by trying to pick up which of the two variants we have, and deciding accordingly. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
Diffstat (limited to 'git-arr')
-rwxr-xr-xgit-arr12
1 files changed, 11 insertions, 1 deletions
diff --git a/git-arr b/git-arr
index 2a23128..418f883 100755
--- a/git-arr
+++ b/git-arr
@@ -269,6 +269,16 @@ def static(path):
# Static HTML generation
#
+def is_404(e):
+ """True if e is an HTTPError with status 404, False otherwise."""
+ # We need this because older bottle.py versions put the status code in
+ # e.status as an integer, and newer versions make that a string, and using
+ # e.status_code for the code.
+ if isinstance(e.status, int):
+ return e.status == 404
+ else:
+ return e.status_code == 404
+
def generate(output, skip_index = False):
"""Generate static html to the output directory."""
def write_to(path, func_or_str, args = (), mtime = None):
@@ -396,7 +406,7 @@ def generate(output, skip_index = False):
# Some repos can have tags pointing to non-commits. This
# happens in the Linux Kernel's v2.6.11, which points directly
# to a tree. Ignore them.
- if e.status_code == 404:
+ if is_404(e):
print('404 in tag %s (%s)' % (tag_name, obj_id))
else:
raise