simpleTest: use XDG_RUNTIME_DIR for storing temp files
Signed-off-by: hrj <harshad.rj@gmail.com>
This commit is contained in:
parent
433621f046
commit
352424e8f5
|
@ -1,7 +1,9 @@
|
||||||
import http.client
|
import http.client
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
|
tempDir = os.getenv('XDG_RUNTIME_DIR', '.')
|
||||||
conn = http.client.HTTPConnection('localhost', 8888)
|
conn = http.client.HTTPConnection('localhost', 8888)
|
||||||
|
|
||||||
params = """{
|
params = """{
|
||||||
|
@ -24,9 +26,10 @@ def getAndSolve(idStr):
|
||||||
|
|
||||||
if response:
|
if response:
|
||||||
responseBytes = response.read()
|
responseBytes = response.read()
|
||||||
with open("captcha.png", "wb") as f:
|
fileName = tempDir + "/captcha.png"
|
||||||
|
with open(fileName, "wb") as f:
|
||||||
f.write(responseBytes)
|
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()
|
ocrAnswer = ocrResult.stdout.readlines()[0].strip().decode()
|
||||||
return ocrAnswer
|
return ocrAnswer
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue