Compare commits

..

24 Commits

Author SHA1 Message Date
daf3acd8a2 moving to trixie
All checks were successful
/ Plan (push) Successful in 8m17s
/ Plan (pull_request) Successful in 29s
/ Deploy (pull_request) Successful in 25s
2025-08-18 14:39:16 -05:00
56a0f40d01 added the missing period
All checks were successful
/ Plan (push) Successful in 42s
/ Plan (pull_request) Successful in 3m50s
/ Deploy (pull_request) Successful in 14s
2025-01-01 00:27:32 -06:00
45f67c3cce changing logic for ill check
All checks were successful
/ Plan (push) Successful in 50s
/ Plan (pull_request) Successful in 8s
/ Deploy (pull_request) Successful in 18s
2025-01-01 00:23:48 -06:00
6ad7709983 forgot to initialize isill properly
All checks were successful
/ Plan (push) Successful in 1m4s
/ Plan (pull_request) Successful in 9s
/ Deploy (pull_request) Successful in 19s
2025-01-01 00:18:32 -06:00
402b265cdc ILL's first pass
All checks were successful
/ Plan (push) Successful in 5m33s
/ Plan (pull_request) Successful in 12s
/ Deploy (pull_request) Successful in 54s
2024-12-31 23:58:26 -06:00
cb53ade476 Merge pull request 'dev build separate from latest' (#38) from work into main
Reviewed-on: #38
2024-11-26 08:05:48 -06:00
0388bb3641 dev build separate from latest
All checks were successful
/ Plan (push) Successful in 13s
/ Plan (pull_request) Successful in 15s
/ Deploy (pull_request) Successful in 12s
2024-11-26 08:03:57 -06:00
c73f91afe2 Merge pull request 'forcing push' (#37) from work into main
Reviewed-on: #37
2024-11-26 01:56:23 -06:00
8680121a04 forcing push
All checks were successful
/ Plan (push) Successful in 6s
/ Plan (pull_request) Successful in 7s
/ Deploy (pull_request) Successful in 13s
2024-11-26 01:55:59 -06:00
eb6c9931df Merge pull request 'fixing order' (#36) from work into main
Reviewed-on: #36
2024-11-26 01:54:29 -06:00
500299f7a0 fixing order
All checks were successful
/ Plan (push) Successful in 14s
2024-11-26 01:53:25 -06:00
6deb3b4f3b Merge pull request 'finalize deployment automation' (#35) from work into main
Reviewed-on: #35
2024-11-26 01:49:34 -06:00
3dc9042a36 finalize deployment automation
All checks were successful
/ Plan (push) Successful in 12s
/ Plan (pull_request) Successful in 14s
/ Deploy (pull_request) Successful in 4s
2024-11-26 01:48:27 -06:00
abf5ba1952 Merge pull request 'crontab works, moving to correct time' (#34) from work into main
Reviewed-on: #34
2024-11-26 01:16:02 -06:00
4cc6c8daed crontab works, moving to correct time
All checks were successful
/ Plan (push) Successful in 38s
/ Plan (pull_request) Successful in 18s
2024-11-26 01:15:47 -06:00
8bdaf5c1b9 Merge pull request 'Crontab changes' (#33) from work into main
Reviewed-on: #33
2024-11-26 01:09:28 -06:00
96011017bc Crontab changes
All checks were successful
/ Plan (push) Successful in 32s
/ Plan (pull_request) Successful in 19s
2024-11-26 01:08:34 -06:00
0dc6a1d8c7 Merge pull request 'Added a space for last updated.' (#32) from work into main
Reviewed-on: #32
2024-11-26 00:57:07 -06:00
e914656041 newline
All checks were successful
/ Plan (push) Successful in 39s
/ Plan (pull_request) Successful in 21s
2024-11-26 00:56:41 -06:00
9f2b8de131 Added a space for last updated.
All checks were successful
/ Plan (push) Successful in 36s
2024-11-26 00:53:24 -06:00
a32b996b13 Merge pull request 'add newline after total table' (#31) from work into main
Reviewed-on: #31
2024-11-26 00:24:14 -06:00
d1ae8faad3 add newline after total table
All checks were successful
/ Plan (push) Successful in 41s
/ Plan (pull_request) Successful in 19s
2024-11-26 00:23:04 -06:00
750ab3d85d Merge pull request 'fix table mistake' (#30) from work into main
Reviewed-on: #30
2024-11-26 00:21:07 -06:00
e70e1c7757 fix table mistake
All checks were successful
/ Plan (push) Successful in 35s
/ Plan (pull_request) Successful in 14s
2024-11-26 00:20:52 -06:00
5 changed files with 54 additions and 23 deletions

View File

@@ -25,4 +25,5 @@ jobs:
- name: Deploy - name: Deploy
run: | run: |
echo "${{ secrets.GITEASECRET_TOKEN }}" | docker login git.hamik.net -u paradizelost --password-stdin echo "${{ secrets.GITEASECRET_TOKEN }}" | docker login git.hamik.net -u paradizelost --password-stdin
docker build -t git.hamik.net/paradizelost/librarynotices:latest . docker build -t git.hamik.net/paradizelost/librarynotices:dev .
docker push git.hamik.net/paradizelost/librarynotices:dev

View File

@@ -22,3 +22,21 @@ jobs:
echo "${{ secrets.GITEASECRET_TOKEN }}" | docker login git.hamik.net -u paradizelost --password-stdin echo "${{ secrets.GITEASECRET_TOKEN }}" | docker login git.hamik.net -u paradizelost --password-stdin
docker build -t git.hamik.net/paradizelost/librarynotices:latest . docker build -t git.hamik.net/paradizelost/librarynotices:latest .
docker push git.hamik.net/paradizelost/librarynotices docker push git.hamik.net/paradizelost/librarynotices
Deploy:
needs: [Plan] #
runs-on: librarynoticehost
defaults:
run:
working-directory: /docker/librarynotices
steps:
- name: Destroy Container
id: down
run: docker compose down
- name: Pull Updates
id: pull
run: docker compose pull
- name: Start Containers
id: start
run: docker compose up -d

View File

@@ -1,18 +1,9 @@
FROM debian:bullseye-slim FROM debian:trixie-slim
# #
RUN apt update && apt install cron apache2 python3 python3-pip php libapache2-mod-php -y COPY requirements.txt crontab init.sh /
RUN a2enmod php*
COPY crontab /etc/cron.d/crontab
COPY refresh.php /var/www/html/ COPY refresh.php /var/www/html/
RUN apt update && apt install cron apache2 python3 python3-pip php libapache2-mod-php -y && pip3 install -r /requirements.txt --break-system-packages && apt clean && a2enmod php* && chmod +x /init.sh && mkdir /var/www/.aws
COPY libnotices.py /usr/local/bin/ COPY libnotices.py /usr/local/bin/
COPY requirements.txt / RUN chmod +x /usr/local/bin/libnotices.py && chown www-data:www-data /var/www -R && crontab -u www-data /crontab
COPY init.sh /
RUN chmod +x /init.sh
RUN pip3 install -r /requirements.txt
RUN mkdir /var/www/.aws
RUN chmod +x /usr/local/bin/libnotices.py
RUN chown www-data:www-data /var/www -R
RUN apt clean
EXPOSE 80 EXPOSE 80
CMD ["/init.sh"] CMD ["/init.sh"]
#(cron -l 8 & ) && su - www-data -s /usr/local/bin/libnotices.py & apache2ctl -D FOREGROUND]

View File

@@ -1 +1 @@
45 4 * * * www-data python3 /usr/local/bin/libnotices.py 0 17 * * * python3 /usr/local/bin/libnotices.py

View File

@@ -6,6 +6,7 @@ import boto3
import json import json
from json import JSONEncoder from json import JSONEncoder
import logging import logging
import re
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
class libaccount(dict): class libaccount(dict):
@@ -17,7 +18,7 @@ class libaccount(dict):
def toJson(self): def toJson(self):
return json.dumps(self,default=lambda o: o.__dict__) return json.dumps(self,default=lambda o: o.__dict__)
class book(): class book():
def __init__(self,itemid,renewalcount,checkoutdate,duedate,vendor,resourceid,title,materialtype,coverurl,person,authsession,renewresult,overdue,isbn): def __init__(self,itemid,renewalcount,checkoutdate,duedate,vendor,resourceid,title,materialtype,coverurl,person,authsession,renewresult,overdue,isbn,isill):
self.id=itemid self.id=itemid
self.renewalcount=renewalcount self.renewalcount=renewalcount
self.checkoutdate=checkoutdate self.checkoutdate=checkoutdate
@@ -32,6 +33,7 @@ class book():
self.renewresult=renewresult self.renewresult=renewresult
self.overdue=overdue self.overdue=overdue
self.isbn=isbn self.isbn=isbn
self.isill=isill
#self.ill=ill #self.ill=ill
def print(self): def print(self):
print(self.person, self.id, self.title, self.checkoutdate, self.renewalcount, self.duedate, self.materialtype,self.renewresult, self.isbn) print(self.person, self.id, self.title, self.checkoutdate, self.renewalcount, self.duedate, self.materialtype,self.renewresult, self.isbn)
@@ -129,6 +131,7 @@ for myaccount in accounts:
outs = session.get(checkoutsuri) outs = session.get(checkoutsuri)
if len(outs.json()) >=1: if len(outs.json()) >=1:
for mybook in outs.json(): for mybook in outs.json():
isill=False
if mybook['vendor']=='overdrive': if mybook['vendor']=='overdrive':
continue continue
if mybook['vendor']=='hoopla': if mybook['vendor']=='hoopla':
@@ -137,6 +140,9 @@ for myaccount in accounts:
myisbn = mybook['resource']['coverUrl']['small'].split('=')[1].split("/")[0] myisbn = mybook['resource']['coverUrl']['small'].split('=')[1].split("/")[0]
except: except:
myisbn='' myisbn=''
if myisbn=='':
if re.match(".*ILL",mybook['resource']['title']):
isill=True
try: try:
mycoverurl = mybook['resource']['coverUrl']['small'] mycoverurl = mybook['resource']['coverUrl']['small']
except: except:
@@ -165,7 +171,8 @@ for myaccount in accounts:
session, session,
'None', 'None',
overdue, overdue,
myisbn myisbn,
isill
) )
if thisbook.materialtype in mediatypes: if thisbook.materialtype in mediatypes:
pass pass
@@ -192,7 +199,7 @@ TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black;}
</style><table>""" </style><table>"""
tableend="</table> </body></html>" tableend="</table> </body></html>"
timezone = ZoneInfo("America/Chicago") timezone = ZoneInfo("America/Chicago")
returntable="Last Updated" + str(datetime.datetime.now(timezone)) returntable="Last Updated<BR> " + str(datetime.datetime.now(timezone))
returntable+='<br>Click <a href="https://librarynotice.hamik.net">Here</a> to visit the site.' returntable+='<br>Click <a href="https://librarynotice.hamik.net">Here</a> to visit the site.'
returntable += """<form action="https://librarynotice.hamik.net/refresh.php"> returntable += """<form action="https://librarynotice.hamik.net/refresh.php">
<input type="submit" value="Refresh Items"> <input type="submit" value="Refresh Items">
@@ -208,8 +215,22 @@ for account in accounts:
accountcount = sum(b.person == account.name for b in allbooks) accountcount = sum(b.person == account.name for b in allbooks)
if accountcount >0: if accountcount >0:
returntable += "<tr><td>" + account.name + td + str(accountcount) + "</td></tr>" returntable += "<tr><td>" + account.name + td + str(accountcount) + "</td></tr>"
totalcheckedout = len(allbooks) totalcheckedout = len(allbooks)
returntable += "<tr><td><b>Total" + td + str(totalcheckedout) + "</b></td></tr>" + tableend returntable += "<tr><td><b>Total" + td + str(totalcheckedout) + "</b></td></tr>" + tableend + "<BR>"
ills = [d for d in allbooks if (d.isill==True)]
if len(ills) >=1:
returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Type'+ th +'Count</th></tr>'
for type in mediatypes:
typecount = sum(b.materialtype == type for b in ills)
if typecount>0:
returntable += "<tr><td>" + type + td + str(typecount) + "</td></tr>"
totalreturnbooks = len(ills)
returntable += "<tr><td><b>" + "Total" + td + str(totalreturnbooks) + "</b></td></tr>"
returntable += tableend + "<br>"
returntable += tablestart + "<colgroup><col/><col/><col/><col/><col/><col/><col/><col/></colgroup><tr><th>Name"+th+"Type"+th+"Times Renewed"+ th + "Renewal Status" + th+"Checked Out"+th+"Due Date"+th+"Title" + th + "ISBN" + th + "Thumbnail</th></tr>"
for item in ills:
returntable += "<TR><TD>" + item.person + td + item.materialtype + td + str(item.renewalcount) + td + str(item.renewresult)+ td + str(item.checkoutdate) + td + str(item.duedate) + td + item.title + td + item.isbn + td +'<img src="'+ item.coverurl+'">' +"</td></tr>\n"
returntable += tableend + "<BR>"
duesoon = [d for d in allbooks if (d.duedate < datetime.date.today() + datetime.timedelta(days=10)) and not (str(d.renewresult).lower() == 'None'.lower())] duesoon = [d for d in allbooks if (d.duedate < datetime.date.today() + datetime.timedelta(days=10)) and not (str(d.renewresult).lower() == 'None'.lower())]
if len(duesoon) >=1: if len(duesoon) >=1:
returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Type'+ th +'Count</th></tr>' returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Type'+ th +'Count</th></tr>'