22
22
from osgeo .gdalconst import GA_ReadOnly
23
23
from qgis .server import QgsServer , QgsAccessControlFilter
24
24
from qgis .core import QgsRenderChecker
25
+ import tempfile
25
26
26
27
27
28
XML_NS = \
@@ -990,7 +991,7 @@ def _post_restricted(self, data, query_string=None):
990
991
return result
991
992
992
993
def _img_diff (self , image , control_image , max_diff ):
993
- temp_image = "/tmp/ %s_result.png" % control_image
994
+ temp_image = path . join ( tempfile . gettempdir (), " %s_result.png" % control_image )
994
995
with open (temp_image , "w" ) as f :
995
996
f .write (image )
996
997
@@ -1006,23 +1007,23 @@ def _img_diff_error(self, response, headers, image, max_diff=10):
1006
1007
"Content type is wrong: %s" % headers .get ("Content-Type" ))
1007
1008
test , report = self ._img_diff (response , image , max_diff )
1008
1009
1009
- result_img = check_output (["base64" , "/tmp/" + image + "_result.png" ])
1010
- message = "Image is wrong\n %s\n Image:\n echo '%s' | base64 -d > /tmp /%s_result.png" % (
1011
- report , result_img .strip (), image
1010
+ result_img = check_output (["base64" , path . join ( tempfile . gettempdir (), image + "_result.png" ) ])
1011
+ message = "Image is wrong\n %s\n Image:\n echo '%s' | base64 -d >%s /%s_result.png" % (
1012
+ report , result_img .strip (), tempfile . gettempdir (), image
1012
1013
)
1013
1014
1014
- if path .isfile ("/tmp/" + image + "_result_diff.png" ):
1015
- diff_img = check_output (["base64" , "/tmp/" + image + "_result_diff.png" ])
1016
- message += "\n Diff:\n echo '%s' | base64 -d > /tmp /%s_result_diff.png" % (
1017
- diff_img .strip (), image
1015
+ if path .isfile (path . join ( tempfile . gettempdir (), image + "_result_diff.png" ) ):
1016
+ diff_img = check_output (["base64" , path . join ( tempfile . gettempdir (), image + "_result_diff.png" ) ])
1017
+ message += "\n Diff:\n echo '%s' | base64 -d > %s /%s_result_diff.png" % (
1018
+ diff_img .strip (), tempfile . gettempdir (), image
1018
1019
)
1019
1020
self .assertTrue (test , message )
1020
1021
1021
1022
def _geo_img_diff (self , image_1 , image_2 ):
1022
1023
1023
- with open ("/tmp/" + image_2 , "w" ) as f :
1024
+ with open (path . join ( tempfile . gettempdir (), image_2 ) , "w" ) as f :
1024
1025
f .write (image_1 )
1025
- image_1 = gdal .Open ("/tmp/" + image_2 , GA_ReadOnly )
1026
+ image_1 = gdal .Open (path . join ( tempfile . gettempdir (), image_2 ) , GA_ReadOnly )
1026
1027
1027
1028
image_2 = gdal .Open (self .testdata_path + "/results/" + image_2 , GA_ReadOnly )
1028
1029
0 commit comments