Compare commits

..

2 Commits

Author SHA1 Message Date
Anton Zadvorny
a065557028 Make all paths absolute 2020-01-22 17:30:11 +03:00
Anton Zadvorny
fcccdc71aa Fix cron period 2020-01-22 17:29:46 +03:00
3 changed files with 9 additions and 9 deletions

View File

@ -4,7 +4,7 @@ ENV TZ=Europe/Moscow
ENV TERM=xterm-color
RUN apt-get update && \
apt-get install -y --no-install-recommends cron python3 python3-pymysql python3-qrcode p7zip && \
apt-get install -y --no-install-recommends cron python3 python3-pymysql python3-qrcode p7zip-full && \
rm -rf /var/lib/apt/lists/*
RUN \

View File

@ -1 +1 @@
* * * * * root . /etc/environment; python3 /opt/gtfs2qr/gtfs2qr.py > /opt/gtfs2qr/logs.log 2>&1
0 * * * * root . /etc/environment; python3 /opt/gtfs2qr/gtfs2qr.py >> /opt/gtfs2qr/logs.log 2>&1

View File

@ -53,16 +53,16 @@ def main():
)
cursor = conn.cursor()
if op.exists('codes.7z'):
os.unlink('codes.7z')
if op.exists('/opt/gtfs2qr/codes.7z'):
os.unlink('/opt/gtfs2qr/codes.7z')
shutil.rmtree('codes', ignore_errors=True)
shutil.rmtree('/opt/gtfs2qr/codes', ignore_errors=True)
cursor.execute('SELECT * FROM routes ORDER BY route_short_name;')
for route in cursor.fetchall():
for d in (0, 1):
route_path = op.join(
'codes',
'/opt/gtfs2qr/codes',
transport_type[route['transport_type']],
route['route_short_name'],
'туда' if d == 0 else 'обратно'
@ -96,7 +96,7 @@ def main():
img = qr.make_image(fill_color="black", back_color="white")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("Verdana.ttf", 12)
font = ImageFont.truetype("/opt/gtfs2qr/Verdana.ttf", 12)
stop_name += ' (%i)' % stop['stop_id']
text_size = font.getsize(stop_name)
draw.text(((img.size[0] - text_size[0]) / 2, img.size[1] - 25), stop_name, font=font)
@ -106,13 +106,13 @@ def main():
qr.clear()
subprocess.run(['7za', 'a', 'codes', 'codes'], check=True)
subprocess.run(['7za', 'a', '/opt/gtfs2qr/codes.7z', '/opt/gtfs2qr/codes'], check=True)
with ftplib.FTP(host=FTP_HOST, user=FTP_USER, passwd=FTP_PASS) as ftp:
if 'codes.7z' in ftp.nlst():
ftp.delete('codes.7z')
with open('codes.7z', 'rb') as arch:
with open('/opt/gtfs2qr/codes.7z', 'rb') as arch:
ftp.storbinary('STOR codes.7z', arch)