From 0be5debf7abfeab93a71880fe537dae6c144e994 Mon Sep 17 00:00:00 2001 From: taozywu Date: Wed, 27 Nov 2019 17:02:20 +0800 Subject: [PATCH] Change 'os.path.expanduser' func to 'tempfile.gettempdir' func for create the temp dir. --- MyQR/myqr.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MyQR/myqr.py b/MyQR/myqr.py index 458bb4e..9f9198b 100644 --- a/MyQR/myqr.py +++ b/MyQR/myqr.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +import tempfile import os from MyQR.mylibs import theqrmodule from PIL import Image @@ -84,8 +85,9 @@ def combine(ver, qr_name, bg_name, colorized, contrast, brightness, save_dir, sa qr_name = os.path.join(save_dir, os.path.splitext(os.path.basename(bg_name))[0] + '_qrcode.png') if not save_name else os.path.join(save_dir, save_name) qr.resize((qr.size[0]*3, qr.size[1]*3)).save(qr_name) return qr_name - - tempdir = os.path.join(os.path.expanduser('~'), '.myqr') + + + tempdir = os.path.join(tempfile.gettempdir(), '.myqr') try: if not os.path.exists(tempdir): @@ -129,4 +131,4 @@ def combine(ver, qr_name, bg_name, colorized, contrast, brightness, save_dir, sa finally: import shutil if os.path.exists(tempdir): - shutil.rmtree(tempdir) \ No newline at end of file + shutil.rmtree(tempdir)