Compare commits
24 Commits
8dcac00c34
...
work
Author | SHA1 | Date | |
---|---|---|---|
daf3acd8a2 | |||
56a0f40d01 | |||
45f67c3cce | |||
6ad7709983 | |||
402b265cdc | |||
cb53ade476 | |||
0388bb3641 | |||
c73f91afe2 | |||
8680121a04 | |||
eb6c9931df | |||
500299f7a0 | |||
6deb3b4f3b | |||
3dc9042a36 | |||
abf5ba1952 | |||
4cc6c8daed | |||
8bdaf5c1b9 | |||
96011017bc | |||
0dc6a1d8c7 | |||
e914656041 | |||
9f2b8de131 | |||
a32b996b13 | |||
d1ae8faad3 | |||
750ab3d85d | |||
e70e1c7757 |
@@ -25,4 +25,5 @@ jobs:
|
||||
- name: Deploy
|
||||
run: |
|
||||
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
|
@@ -21,4 +21,22 @@ jobs:
|
||||
run: |
|
||||
echo "${{ secrets.GITEASECRET_TOKEN }}" | docker login git.hamik.net -u paradizelost --password-stdin
|
||||
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
|
19
Dockerfile
19
Dockerfile
@@ -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
|
||||
RUN a2enmod php*
|
||||
COPY crontab /etc/cron.d/crontab
|
||||
COPY requirements.txt crontab init.sh /
|
||||
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 requirements.txt /
|
||||
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
|
||||
RUN chmod +x /usr/local/bin/libnotices.py && chown www-data:www-data /var/www -R && crontab -u www-data /crontab
|
||||
EXPOSE 80
|
||||
CMD ["/init.sh"]
|
||||
#(cron -l 8 & ) && su - www-data -s /usr/local/bin/libnotices.py & apache2ctl -D FOREGROUND]
|
||||
CMD ["/init.sh"]
|
2
crontab
2
crontab
@@ -1 +1 @@
|
||||
45 4 * * * www-data python3 /usr/local/bin/libnotices.py
|
||||
0 17 * * * python3 /usr/local/bin/libnotices.py
|
||||
|
@@ -6,6 +6,7 @@ import boto3
|
||||
import json
|
||||
from json import JSONEncoder
|
||||
import logging
|
||||
import re
|
||||
from zoneinfo import ZoneInfo
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
class libaccount(dict):
|
||||
@@ -17,7 +18,7 @@ class libaccount(dict):
|
||||
def toJson(self):
|
||||
return json.dumps(self,default=lambda o: o.__dict__)
|
||||
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.renewalcount=renewalcount
|
||||
self.checkoutdate=checkoutdate
|
||||
@@ -32,6 +33,7 @@ class book():
|
||||
self.renewresult=renewresult
|
||||
self.overdue=overdue
|
||||
self.isbn=isbn
|
||||
self.isill=isill
|
||||
#self.ill=ill
|
||||
def print(self):
|
||||
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)
|
||||
if len(outs.json()) >=1:
|
||||
for mybook in outs.json():
|
||||
isill=False
|
||||
if mybook['vendor']=='overdrive':
|
||||
continue
|
||||
if mybook['vendor']=='hoopla':
|
||||
@@ -136,7 +139,10 @@ for myaccount in accounts:
|
||||
try:
|
||||
myisbn = mybook['resource']['coverUrl']['small'].split('=')[1].split("/")[0]
|
||||
except:
|
||||
myisbn=''
|
||||
myisbn=''
|
||||
if myisbn=='':
|
||||
if re.match(".*ILL",mybook['resource']['title']):
|
||||
isill=True
|
||||
try:
|
||||
mycoverurl = mybook['resource']['coverUrl']['small']
|
||||
except:
|
||||
@@ -165,7 +171,8 @@ for myaccount in accounts:
|
||||
session,
|
||||
'None',
|
||||
overdue,
|
||||
myisbn
|
||||
myisbn,
|
||||
isill
|
||||
)
|
||||
if thisbook.materialtype in mediatypes:
|
||||
pass
|
||||
@@ -192,7 +199,7 @@ TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black;}
|
||||
</style><table>"""
|
||||
tableend="</table> </body></html>"
|
||||
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 += """<form action="https://librarynotice.hamik.net/refresh.php">
|
||||
<input type="submit" value="Refresh Items">
|
||||
@@ -208,8 +215,22 @@ for account in accounts:
|
||||
accountcount = sum(b.person == account.name for b in allbooks)
|
||||
if accountcount >0:
|
||||
returntable += "<tr><td>" + account.name + td + str(accountcount) + "</td></tr>"
|
||||
totalcheckedout = len(allbooks)
|
||||
returntable += "<tr><td><b>Total" + td + str(totalcheckedout) + "</b></td></tr>" + tableend
|
||||
totalcheckedout = len(allbooks)
|
||||
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())]
|
||||
if len(duesoon) >=1:
|
||||
returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Type'+ th +'Count</th></tr>'
|
||||
|
Reference in New Issue
Block a user