Changeset 316b9c1 in sasview for src/sas/sasview/sasview.py


Ignore:
Timestamp:
Jun 11, 2018 9:30:11 AM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
Children:
c7634fd, 9e96dbd, 8a51dea0
Parents:
9258c43c (diff), 1270e3c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Kienzle <pkienzle@…> (06/11/18 09:30:11)
git-committer:
GitHub <noreply@…> (06/11/18 09:30:11)
Message:

Merge pull request #155 from SasView?/ticket-1084

Checking cc compiler on OSX prior to sasmodel installation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasview/sasview.py

    r20fa5fe r1270e3c  
    4343        from sas.sasgui.guiframe.gui_manager import SasViewApp 
    4444        self.gui = SasViewApp(0) 
     45        if sys.platform == "darwin": 
     46            self.check_sasmodels_compiler() 
    4547        # Set the application manager for the GUI 
    4648        self.gui.set_manager(self) 
     
    130132        self.gui.MainLoop() 
    131133 
     134    def check_sasmodels_compiler(self): 
     135        """ 
     136        Checking c compiler for sasmodels and raises xcode command line 
     137        tools for installation 
     138        """ 
     139        #wx should be importable at this stage 
     140        import wx 
     141        import subprocess 
     142        #Generic message box created becuase standard MessageBox is not moveable 
     143        class GenericMessageBox(wx.Dialog): 
     144            def __init__(self, parent, text, title = ''): 
     145 
     146                wx.Dialog.__init__(self, parent, -1, title = title, 
     147                               size = (360,200), pos=(20,60), 
     148                               style = wx.STAY_ON_TOP | wx.DEFAULT_DIALOG_STYLE) 
     149                panel = wx.Panel(self, -1) 
     150                top_row_sizer = wx.BoxSizer(wx.HORIZONTAL) 
     151 
     152                error_bitmap = wx.ArtProvider.GetBitmap( 
     153                    wx.ART_ERROR, wx.ART_MESSAGE_BOX 
     154                ) 
     155                error_bitmap_ctrl = wx.StaticBitmap(panel, -1) 
     156                error_bitmap_ctrl.SetBitmap(error_bitmap) 
     157                label = wx.StaticText(panel, -1, text) 
     158                top_row_sizer.Add(error_bitmap_ctrl, flag=wx.ALL, border=10) 
     159                top_row_sizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL) 
     160 
     161                #Create the OK button in the bottom row. 
     162                ok_button = wx.Button(panel, wx.ID_OK ) 
     163                self.Bind(wx.EVT_BUTTON, self.on_ok, source=ok_button) 
     164                ok_button.SetFocus() 
     165                ok_button.SetDefault() 
     166 
     167                sizer = wx.BoxSizer(wx.VERTICAL) 
     168                sizer.Add(top_row_sizer) 
     169                sizer.Add(ok_button, flag=wx.ALIGN_CENTER | wx.ALL, border=5) 
     170                panel.SetSizer(sizer) 
     171 
     172            def on_ok(self, event): 
     173                self.Destroy() 
     174 
     175        logger = logging.getLogger(__name__) 
     176        try: 
     177            subprocess.check_output(["cc","--version"], stderr=subprocess.STDOUT) 
     178        except subprocess.CalledProcessError as exc: 
     179            dlg = GenericMessageBox(parent=None, 
     180            text='No compiler installed. Please install command line\n' 
     181                'developers tools by clicking \"Install\" in another winodw\n\n' 
     182                'Alternatively click \"Not Now\" and use OpenCL\n' 
     183                 'compiler, which can be set up from menu Fitting->OpenCL Options\n\n', 
     184            title = 'Compiler Info') 
     185            dlg.Show() 
     186            logger.error("No compiler installed. %s\n"%(exc)) 
     187            logger.error(traceback.format_exc()) 
    132188 
    133189def setup_logging(): 
Note: See TracChangeset for help on using the changeset viewer.