aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auxiliary/86_library_cron2
-rwxr-xr-xauxiliary/library.sh5
-rw-r--r--libraries/polaris.py5
-rwxr-xr-xlibrary_info_cli.py16
4 files changed, 26 insertions, 2 deletions
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("<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")
bgstack15