From 352424e8f5169b39ebc9cd70785df59bf4069745 Mon Sep 17 00:00:00 2001 From: hrj Date: Wed, 14 Apr 2021 10:00:36 +0530 Subject: [PATCH] simpleTest: use XDG_RUNTIME_DIR for storing temp files Signed-off-by: hrj --- scripts/simpleTest.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/simpleTest.py b/scripts/simpleTest.py index 4503199..04f260b 100644 --- a/scripts/simpleTest.py +++ b/scripts/simpleTest.py @@ -1,7 +1,9 @@ import http.client import json import subprocess +import os +tempDir = os.getenv('XDG_RUNTIME_DIR', '.') conn = http.client.HTTPConnection('localhost', 8888) params = """{ @@ -24,9 +26,10 @@ def getAndSolve(idStr): if response: responseBytes = response.read() - with open("captcha.png", "wb") as f: + fileName = tempDir + "/captcha.png" + with open(fileName, "wb") as f: f.write(responseBytes) - ocrResult = subprocess.Popen("gocr captcha.png", shell=True, stdout=subprocess.PIPE) + ocrResult = subprocess.Popen("gocr " + fileName, shell=True, stdout=subprocess.PIPE) ocrAnswer = ocrResult.stdout.readlines()[0].strip().decode() return ocrAnswer