source: branch/2frame/GSASII.py @ 2899

Last change on this file since 2899 was 2899, checked in by toby, 5 years ago

partial reorg

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Author Revision URL Id
File size: 4.9 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#GSASII
4########### SVN repository information ###################
5# $Date: 2017-07-03 21:12:45 +0000 (Mon, 03 Jul 2017) $
6# $Author: toby $
7# $Revision: 2899 $
8# $URL: branch/2frame/GSASII.py $
9# $Id: GSASII.py 2899 2017-07-03 21:12:45Z toby $
10########### SVN repository information ###################
11'''
12*GSAS-II Main Module*
13=====================
14
15Main routines for the GSAS-II program
16'''
17
18import os
19import sys
20
21__version__ = '0.3.0'
22
23# PATCH: for Mavericks (OS X 10.9.x), wx produces an annoying warning about LucidaGrandeUI.
24# In case stderr has been suppressed there, redirect python error output to stdout. Nobody
25# else should care much about this.
26sys.stderr = sys.stdout
27
28#def create(parent):
29#    return GSASII(parent)
30
31# class GSASIIsplit(wx.SplitterWindow):
32#     def __init__(self,parent,ID):
33#         wx.SplitterWindow.__init__(self, parent, ID,style = wx.SP_BORDER|wx.SP_LIVE_UPDATE)
34#         self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChanged)
35#         self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChanging)
36
37#     def OnSashChanged(self, evt):
38#         evt.Skip()
39# #        print "sash changed to %s\n" % str(evt.GetSashPosition())
40
41#     def OnSashChanging(self, evt):
42#         evt.Skip()
43# #        print "sash changing to %s\n" % str(evt.GetSashPosition())
44   
45if __name__ == '__main__':
46    import numpy as np
47    import scipy as sp
48    import wx
49    import wx.lib.scrolledpanel as wxscroll
50    try:  # patch for LANG environment var problem on occasional OSX machines
51        import locale
52        locale.getdefaultlocale()
53    except ValueError:
54        print('Fixing location (see https://github.com/matplotlib/matplotlib/issues/5420.)')
55        os.environ['LC_ALL'] = 'en_US.UTF-8'
56        locale.getdefaultlocale()
57    import matplotlib as mpl
58    try:
59        import OpenGL as ogl
60    except ImportError:
61        print('*******************************************************')
62        print('PyOpenGL is missing from your python installation')
63        print('     - we will try to install it')
64        print('*******************************************************')
65        def install_with_easyinstall(package):
66            try: 
67                print "trying a system-wide PyOpenGl install"
68                easy_install.main(['-f',os.path.split(__file__)[0],package])
69                return
70            except:
71                pass
72            try: 
73                print "trying a user level PyOpenGl install"
74                easy_install.main(['-f',os.path.split(__file__)[0],'--user',package])
75                return
76            except:
77                print "Install of '+package+' failed. Please report this information:"
78                import traceback
79                print traceback.format_exc()
80                sys.exit()
81        from setuptools.command import easy_install
82        install_with_easyinstall('PyOpenGl')
83        print('*******************************************************')         
84        print('OpenGL has been installed. Restarting GSAS-II')
85        print('*******************************************************')         
86        loc = os.path.dirname(__file__)
87        import subprocess
88        subprocess.Popen([sys.executable,os.path.join(loc,'GSASII.py')])
89        sys.exit()
90
91    # load the GSAS routines
92    import GSASIIpath
93    GSASIIpath.SetVersionNumber("$Revision: 2899 $")
94    import GSASIIIO as G2IO
95    import GSASIIElem as G2elem
96    import GSASIIgrid as G2gd
97    import GSASIIctrls as G2G
98    import GSASIIplot as G2plt
99    import GSASIIpwd as G2pwd
100    import GSASIIpwdGUI as G2pdG
101    import GSASIIspc as G2spc
102    import GSASIIstrMain as G2stMn
103    import GSASIIstrIO as G2stIO
104    import GSASIImath as G2mth
105    import GSASIImapvars as G2mv
106    import GSASIIobj as G2obj
107    import GSASIIlattice as G2lat
108    import GSASIIlog as log
109#                GSASIIpath.IPyBreak()
110    # print versions
111    print "Python module versions loaded:"
112    print "  Python:     ",sys.version.split()[0]
113    print "  wx:         ",wx.__version__
114    print "  matplotlib: ",mpl.__version__
115    print "  numpy:      ",np.__version__
116    print "  scipy:      ",sp.__version__
117    print "  OpenGL:     ",ogl.__version__
118    try:
119        from PIL import Image
120        try:
121            from PIL import PILLOW_VERSION
122            version = PILLOW_VERSION
123        except:
124            version = Image.VERSION
125        print "  PIL.Image:  ",version
126    except ImportError:
127        try:
128            import Image
129            print "Image (PIL):",Image.VERSION
130        except ImportError:
131            print "Image module not present; Note that PIL (Python Imaging Library) or pillow is needed for some image operations"
132    import platform
133    print "  Platform:   ",sys.platform,platform.architecture()[0],platform.machine()
134    try:
135        import mkl
136        print "  Max threads:",mkl.get_max_threads()
137    except:
138        pass
139    #print "wxPython description",wx.PlatformInfo
140    print "This is GSAS-II revision "+str(GSASIIpath.GetVersionNumber())+'\n'
141    GSASIIpath.InvokeDebugOpts()
142    G2gd.GSASIImain() # start the GUI
Note: See TracBrowser for help on using the repository browser.