From a06555702816aa8c5103a2642f7dacafeec155e8 Mon Sep 17 00:00:00 2001 From: Anton Zadvorny Date: Wed, 22 Jan 2020 17:30:11 +0300 Subject: [PATCH] Make all paths absolute --- gtfs2qr/gtfs2qr/gtfs2qr.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gtfs2qr/gtfs2qr/gtfs2qr.py b/gtfs2qr/gtfs2qr/gtfs2qr.py index 699df0b..c0e3479 100644 --- a/gtfs2qr/gtfs2qr/gtfs2qr.py +++ b/gtfs2qr/gtfs2qr/gtfs2qr.py @@ -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)