From 0c82f4f4bb78c995b6175a01967b2dc0a1ecb3cb Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Tue, 9 Jul 2024 19:33:30 -0400 Subject: add el8+py3.6 support --- auxiliary/86_library_cron | 2 ++ auxiliary/library.sh | 5 +++++ libraries/polaris.py | 5 +++++ library_info_cli.py | 16 ++++++++++++++-- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 auxiliary/86_library_cron create mode 100755 auxiliary/library.sh diff --git a/auxiliary/86_library_cron b/auxiliary/86_library_cron new file mode 100644 index 0000000..1806957 --- /dev/null +++ b/auxiliary/86_library_cron @@ -0,0 +1,2 @@ +# File: /etc/cron.d/86_library_cron +03 7 * * * root /mnt/public/Support/Programs/library_info/auxiliary/library.sh 1>/var/log/cron_library 2>&1 diff --git a/auxiliary/library.sh b/auxiliary/library.sh new file mode 100755 index 0000000..167edab --- /dev/null +++ b/auxiliary/library.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +# Startdate: 2024-07-09-3 15:45 +# Author: bgstack15 +# Purpose: oneliner for cron job +python3.6 /mnt/public/Support/Programs/library_info/library_info_cli.py --output html --full > /mnt/public/www/library/index.html diff --git a/libraries/polaris.py b/libraries/polaris.py index 8b3037e..a47a289 100644 --- a/libraries/polaris.py +++ b/libraries/polaris.py @@ -14,6 +14,11 @@ from .base import * import requests, dateutil, base64, os, urllib, sys +# for python3.6 on AlmaLinux 8: +try: + import dateutil.parser +except: + pass from bs4 import BeautifulSoup class Library(BaseLibrary): 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("

Accounts: ") prn(", ".join(seen_accounts)) prn("

\n") - prn("Last modified: " + datetime.datetime.now(datetime.UTC).strftime("%FT%TZ") + "\n") + try: + # fails on python36 on almalinux8 + now = datetime.datetime.now(datetime.UTC) + except AttributeError: + now = datetime.datetime.utcnow() + prn("Last modified: " + now.strftime("%FT%TZ") + "\n") if len(items): prn("\n") prn(f"\n") -- cgit
PatronbarcodedueformatcoverTitle