Changeset 085ee014 in sasview


Ignore:
Timestamp:
Oct 1, 2018 3:10:19 AM (3 weeks ago)
Author:
wojciech
Branches:
ESS_GUI, ESS_GUI_project_save
Children:
5047898
Parents:
62c6dc0
Message:

Removing tmp file handling from report logic to make it work on OSX

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/ReportPageLogic.py

    r5330be2 r085ee014  
    9999            canvas = FigureCanvas(fig) 
    100100            png_output = BytesIO() 
    101  
    102             # Create a "safe" location - system tmp 
    103             tmp_file = tempfile.TemporaryFile(suffix=".png") 
    104101            try: 
    105                 fig.savefig(tmp_file.name, dpi=75) 
    106                 fig.savefig(png_output, dpi=75) 
    107             except PermissionError: 
    108                 # sometimes one gets "permission denied" for temp files 
    109                 # mainly on Windows 7 *gasp*. Let's try local directory 
    110                 tmp_file = open("_tmp.png", "w+") 
    111                 try: 
    112                     fig.savefig(tmp_file.name, dpi=75) 
    113                     fig.savefig(png_output, dpi=75) 
    114                 except Exception as ex: 
    115                     logging.error("Creating of the report failed: %s"%str(ex)) 
    116                     return 
    117  
    118             data_to_print = png_output.getvalue() == open(tmp_file.name, 'rb').read() 
    119             tmp_file.close() 
     102                fig.savefig(png_output, format="png", dpi=75) 
     103            except PermissionError as ex: 
     104                logging.error("Creating of the report failed: %s"%str(ex)) 
     105                return 
    120106            data64 = base64.b64encode(png_output.getvalue()) 
    121107            data_to_print = urllib.parse.quote(data64) 
    122  
    123108            feet = FEET_2 
    124109            if sys.platform == "darwin":  # Mac 
     
    126111            html += feet.format(data_to_print) 
    127112            html += ELINE 
     113            png_output.close() 
    128114            del canvas 
    129115        return html 
Note: See TracChangeset for help on using the changeset viewer.