diff options
Diffstat (limited to 'library_info_cli.py')
-rwxr-xr-x | library_info_cli.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/library_info_cli.py b/library_info_cli.py index 49a3b5d..57b9188 100755 --- a/library_info_cli.py +++ b/library_info_cli.py @@ -10,6 +10,7 @@ # Reference: # Improve: # Dependencies: +# dep-almalinux8: python3-requests, python3-dateutil import argparse, sys, json, datetime import library_info_lib @@ -22,7 +23,13 @@ group1 = parser.add_mutually_exclusive_group() group1.add_argument("-s","--single", help="Show this single account.") group1.add_argument("-a","--all", action='store_true', default=True, help="Check all accounts") parser.add_argument("-o","--output", choices=["html","json","raw"], default="raw", help="Output format.") -parser.add_argument("-f","--full", action=argparse.BooleanOptionalAction, default=True, help="Use full image objects or not. They are huge and during debugging it is useful to turn off.") +try: + # This was only added in python 3.9 + parser.add_argument("-f","--full", action=argparse.BooleanOptionalAction, default=True, help="Use full image objects or not. They are huge and during debugging it is useful to turn off.") +except AttributeError: + group2 = parser.add_mutually_exclusive_group() + group2.add_argument("-f","--full", action="store_true", default=True, help="Use full image objects or not. They are huge and during debugging it is useful to turn off.") + group2.add_argument("--no-f","--no-full", action="store_true", default=False) args = parser.parse_args() @@ -78,7 +85,12 @@ def html(items): prn("<h2>Accounts: ") prn(", ".join(seen_accounts)) prn("</h2>\n") - prn("<span class='eighty'>Last modified: " + datetime.datetime.now(datetime.UTC).strftime("%FT%TZ") + "</span>\n") + try: + # fails on python36 on almalinux8 + now = datetime.datetime.now(datetime.UTC) + except AttributeError: + now = datetime.datetime.utcnow() + prn("<span class='eighty'>Last modified: " + now.strftime("%FT%TZ") + "</span>\n") if len(items): prn("<table class='display' id='checkouts'>\n") prn(f"<thead><tr><th>Patron</th><th>barcode</th><th>due</th><th>format</th><th>cover</th><th>Title</th></tr></thead>\n") |