Changeset 2802


Ignore:
Timestamp:
Apr 23, 2017 9:30:38 PM (5 years ago)
Author:
toby
Message:

updates for doc build

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrls.py

    r2769 r2802  
    272272      :obj:`typeHint` and the value for the control is set initially
    273273      blank (and thus invalid.) This is a way to specify a field without a
    274       default value: a user must set a valid value.
     274      default value: a user must set a valid value.
     275       
    275276      If the value is not None, it must have a base
    276277      type of int, float, str or unicode; the TextCrtl will be initialized
     
    278279     
    279280    :param list nDig: number of digits, places and optionally the format
    280      ([nDig,nPlc,fmt]) after decimal to use for display of float. The format
    281      is either 'f' (default) or 'g'. Alternately, None can be specified which
    282      causes numbers to be displayed with approximately 5 significant figures
    283       (Default=None).
     281       ([nDig,nPlc,fmt]) after decimal to use for display of float. The format
     282       is either 'f' (default) or 'g'. Alternately, None can be specified which
     283       causes numbers to be displayed with approximately 5 significant figures
     284       (Default=None).
    284285
    285286    :param bool notBlank: if True (default) blank values are invalid
     
    295296     
    296297    :param list exclLim: if True exclude min/max value ([exclMin,exclMax]);
    297      (Default=[False,False])
     298      (Default=[False,False])
    298299
    299300    :param function OKcontrol: specifies a function or method that will be
     
    310311      The called function is supplied with (at present) three keyword arguments:
    311312
    312          * invalid: (*bool*) True if the value for the TextCtrl is invalid
    313          * value:   (*int/float/str*)  the value contained in the TextCtrl
    314          * tc:      (*wx.TextCtrl*)  the TextCtrl object
     313      * invalid: (*bool*) True if the value for the TextCtrl is invalid
     314      * value:   (*int/float/str*)  the value contained in the TextCtrl
     315      * tc:      (*wx.TextCtrl*)  the TextCtrl object
    315316
    316317      The number of keyword arguments may be increased in the future should needs arise,
     
    339340    :param (other): other optional keyword parameters for the
    340341      wx.TextCtrl widget such as size or style may be specified.
    341 
    342342    '''
    343343    def __init__(self,parent,loc,key,nDig=None,notBlank=True,min=None,max=None,
  • trunk/GSASIIimage.py

    r2788 r2802  
    369369                   
    370370def GetTthAzmDsp(x,y,data): #expensive
    371     '''Computes a 2theta, etc. from a detector position and calibration constants
    372     - checked OK for ellipses & hyperbola
     371    '''Computes a 2theta, etc. from a detector position and calibration constants - checked
     372    OK for ellipses & hyperbola.
     373
    373374    :returns: np.array(tth,azm,G,dsp) where tth is 2theta, azm is the azimutal angle,
    374375       G is ? and dsp is the d-space
  • trunk/GSASIIlattice.py

    r2775 r2802  
    793793    :param ifreverse: True for largest d first
    794794    :param ifdup: True if duplicate d-spacings allowed
    795     :return sorted reflection list
     795    :return: sorted reflection list
    796796    '''
    797797    T = []
     
    909909     
    910910    :param dmin: minimum d-spacing in A
    911     :param Bravais: lattice type (see GetBraviasNum). Bravais is one of::
    912    
    913             0 F cubic
    914             1 I cubic
    915             2 P cubic
    916             3 R hexagonal (trigonal not rhombohedral)
    917             4 P hexagonal
    918             5 I tetragonal
    919             6 P tetragonal
    920             7 F orthorhombic
    921             8 I orthorhombic
    922             9 C orthorhombic
    923             10 P orthorhombic
    924             11 C monoclinic
    925             12 P monoclinic
    926             13 P triclinic
     911    :param Bravais: lattice type (see GetBraviasNum). Bravais is one of:
     912   
     913            * 0 F cubic
     914            * 1 I cubic
     915            * 2 P cubic
     916            * 3 R hexagonal (trigonal not rhombohedral)
     917            * 4 P hexagonal
     918            * 5 I tetragonal
     919            * 6 P tetragonal
     920            * 7 F orthorhombic
     921            * 8 I orthorhombic
     922            * 9 C orthorhombic
     923            * 10 P orthorhombic
     924            * 11 C monoclinic
     925            * 12 P monoclinic
     926            * 13 P triclinic
    927927           
    928928    :param A: reciprocal metric tensor elements as [G11,G22,G33,2*G12,2*G13,2*G23]
     
    12081208    :param str Laue: Laue symbol, as below
    12091209   
    1210       centrosymmetric Laue groups::
     1210      centrosymmetric Laue groups
     1211     
     1212         ::
    12111213       
    1212      ['-1','2/m','112/m','2/m11','mmm','-42m','-4m2','4/mmm','-3','-31m','-3m1','6/m','6/mmm','m3','m3m']
     1214            ['-1','2/m','112/m','2/m11','mmm','-42m','-4m2','4/mmm','-3',
     1215            '-31m','-3m1','6/m','6/mmm','m3','m3m']
    12131216     
    1214       noncentrosymmetric Laue groups::
     1217      noncentrosymmetric Laue groups
     1218
     1219         ::
    12151220     
    1216      ['1','2','211','112','m','m11','11m','222','mm2','m2m','2mm','4','-4','422','4mm','3','312','321','31m','3m1','6','-6','622','6mm','-62m','-6m2','23','432','-43m']
     1221           ['1','2','211','112','m','m11','11m','222','mm2','m2m','2mm',
     1222           '4','-4','422','4mm','3','312','321','31m','3m1','6','-6',
     1223           '622','6mm','-62m','-6m2','23','432','-43m']
    12171224     
    12181225    :param HKLF: np.array([[h,k,l,...]]) reflection set to be converted
    12191226   
    1220     :return: HKLF new reflection array with imposed Laue symmetry
     1227    :returns: HKLF new reflection array with imposed Laue symmetry
    12211228    '''
    12221229   
     
    20682075        tcell = Gmat2cell(G)
    20692076        assert np.allclose(tcell,trcell),msg
    2070 selftestlist.append(test0)
     2077if __name__ == '__main__': selftestlist.append(test0)
    20712078
    20722079def test1():
     
    20792086        assert np.allclose(G,tG),msg
    20802087        assert np.allclose(g,tg),msg
    2081 selftestlist.append(test1)
     2088if __name__ == '__main__': selftestlist.append(test1)
    20822089
    20832090def test2():
     
    20902097        tcell = A2cell(Gmat2A(G))
    20912098        assert np.allclose(cell,tcell),msg
    2092 selftestlist.append(test2)
     2099if __name__ == '__main__': selftestlist.append(test2)
    20932100
    20942101def test3():
     
    21012108        assert np.allclose(G,tG),msg
    21022109        assert np.allclose(g,tg),msg
    2103 selftestlist.append(test3)
     2110if __name__ == '__main__': selftestlist.append(test3)
    21042111
    21052112def test4():
     
    21112118        assert np.allclose(calc_rV(cell2A(cell)),trV), msg
    21122119        assert np.allclose(calc_V(cell2A(cell)),tV), msg
    2113 selftestlist.append(test4)
     2120if __name__ == '__main__': selftestlist.append(test4)
    21142121
    21152122def test5():
     
    21212128        rcell = A2invcell(cell2A(cell))
    21222129        assert np.allclose(rcell,trcell),msg
    2123 selftestlist.append(test5)
     2130if __name__ == '__main__': selftestlist.append(test5)
    21242131
    21252132def test6():
     
    21392146            assert np.allclose(ortho,to), msg
    21402147            assert np.allclose(frac,tf), msg
    2141 selftestlist.append(test6)
     2148if __name__ == '__main__': selftestlist.append(test6)
    21422149
    21432150def test7():
     
    21892196            else:
    21902197                assert 0,'No match for %s at %s (%s)' % ((h,k,l),d,key)
    2191 selftestlist.append(test7)
     2198if __name__ == '__main__': selftestlist.append(test7)
    21922199
    21932200def test8():
     
    22512258            #for hkllist,dref in sgtbxlattinp.sgtbx8[key][1]: print '  ',hkllist,dref
    22522259            #print center, Laue, Axis, system
    2253 selftestlist.append(test8)
     2260if __name__ == '__main__': selftestlist.append(test8)
    22542261           
    22552262def test9():
     
    22762283                err = False
    22772284        assert(err)
    2278 selftestlist.append(test9)
     2285if __name__ == '__main__': selftestlist.append(test9)
    22792286       
    22802287       
  • trunk/GSASIIplot.py

    r2797 r2802  
    2222import wx.glcanvas
    2323import matplotlib as mpl
    24 try:  # code not found in readthedocs
    25     import matplotlib.collections as mplC
    26 except:
    27     print('matplotlib.collections not present')
     24import matplotlib.collections as mplC
    2825import mpl_toolkits.mplot3d.axes3d as mp3d
    2926import GSASIIpath
     
    12061203    Note that plotting information will be found in:
    12071204       G2frame.PatternId (contains the tree item for the current histogram)
     1205       
    12081206       G2frame.PickId (contains the actual selected tree item (can be child of histogram)
     1207
    12091208       G2frame.HKL (used for tool tip display of hkl for selected phase reflection list)
    12101209    '''
     
    28422841    :param str Title: title for plot
    28432842    :param bool lines: = True if lines desired for XY plot; XY2 always plotted as lines
    2844     :param list of str names: legend names for each XY plot
    2845     :param list of str names2: legend names for each XY2 plot
    2846     :param lists of vertical line x-positions list; can be one for each XY
    2847     :return nothing
     2843    :param list names: legend names for each XY plot as list a of str values
     2844    :param list names2: legend names for each XY2 plot as list a of str values
     2845    :param list vertLines: lists of vertical line x-positions; can be one for each XY
     2846    :returns: nothing
    28482847   
    28492848    '''
     
    29642963    :param bool newPlot: =True if new plot is to be made
    29652964    :param str Title: title for plot
    2966     :return nothing
     2965    :returns: nothing
    29672966   
    29682967    '''
     
    43324331    Called from a menu command (GSASIIimgGUI) or from OnImPlotKeyPress.
    43334332    Variable G2frame.MaskKey contains a single letter ('f' or 'p', etc.) that
    4334       determines what type of mask is created.   
     4333    determines what type of mask is created.   
    43354334
    43364335    :param wx.Frame G2frame: The main GSAS-II tree "window"
  • trunk/GSASIIpwd.py

    r2800 r2802  
    7070def PhaseWtSum(G2frame,histo):
    7171    '''
    72     Calculate sum of phase mass*shase fraction for PWDR data (exclude magnetic phases)
     72    Calculate sum of phase mass*phase fraction for PWDR data (exclude magnetic phases)
    7373   
    7474    :param G2frame: GSASII main frame structure
    7575    :param str histo: histogram name
    76     :returns sum(scale*mass) for phases in histo
     76    :returns: sum(scale*mass) for phases in histo
    7777    '''
    7878    Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
     
    22332233    Reflectometry as a function of kz for a set of slabs.
    22342234
    2235     :Parameters:
    2236 
    2237     *kz* : float[n] | |1/Ang|
    2238         Scattering vector $2\pi\sin(\theta)/\lambda$. This is $\tfrac12 Q_z$.
    2239     *depth* :  float[m] | |Ang|
     2235    :param kz: float[n] (1/Ang). Scattering vector, :math:`2\pi\sin(\\theta)/\lambda`.
     2236        This is :math:`\\tfrac12 Q_z`.       
     2237    :param depth:  float[m] (Ang).
    22402238        thickness of each layer.  The thickness of the incident medium
    22412239        and substrate are ignored.
    2242     *rho*, *irho* :  float[n,k] | |1e-6/Ang^2|
    2243         real and imaginary scattering length density for each layer for each kz
     2240    :param rho:  float[n,k] (1e-6/Ang^2)
     2241        Real scattering length density for each layer for each kz
     2242    :param irho:  float[n,k] (1e-6/Ang^2)
     2243        Imaginary scattering length density for each layer for each kz
    22442244        Note: absorption cross section mu = 2 irho/lambda for neutrons
    2245     *sigma* : float[m-1] | |Ang|
     2245    :param sigma: float[m-1] (Ang)
    22462246        interfacial roughness.  This is the roughness between a layer
    22472247        and the previous layer. The sigma array should have m-1 entries.
     
    23682368    '''Simulate powder or selected area diffraction pattern from stacking faults using DIFFaX
    23692369   
    2370     param: Layers dict: 'Laue':'-1','Cell':[False,1.,1.,1.,90.,90.,90,1.],
    2371                         'Width':[[10.,10.],[False,False]],'Toler':0.01,'AtInfo':{},
    2372                         'Layers':[],'Stacking':[],'Transitions':[]}
    2373     param: ctrls string: controls string to be written on DIFFaX controls.dif file
    2374     param: scale float: scale factor
    2375     param: background dict: background parameters
    2376     param: limits list: min/max 2-theta to be calculated
    2377     param: inst dict: instrument parameters dictionary
    2378     param: profile list: powder pattern data
    2379    
    2380     all updated in place   
     2370    :param dict Layers: dict with following items
     2371
     2372      ::
     2373
     2374       {'Laue':'-1','Cell':[False,1.,1.,1.,90.,90.,90,1.],
     2375       'Width':[[10.,10.],[False,False]],'Toler':0.01,'AtInfo':{},
     2376       'Layers':[],'Stacking':[],'Transitions':[]}
     2377       
     2378    :param str ctrls: controls string to be written on DIFFaX controls.dif file
     2379    :param float scale: scale factor
     2380    :param dict background: background parameters
     2381    :param list limits: min/max 2-theta to be calculated
     2382    :param dict inst: instrument parameters dictionary
     2383    :param list profile: powder pattern data
     2384   
     2385    Note that parameters all updated in place   
    23812386    '''
    23822387    import atmdata
  • trunk/GSASIIpwdGUI.py

    r2788 r2802  
    212212       
    213213def SetDefaultREFDModel():
    214     '''Fills in default items for the REFD Models dictionary
    215     Defined as follows for each layer:
    216         Name: name of substance
    217         Thick: thickness of layer in Angstroms (not present for top & bottom layers)
    218         Rough: upper surface roughness for layer (not present for toplayer)
    219         Penetration: mixing of layer substance into layer above-is this needed?
    220         DenMul: multiplier for layer scattering density (default = 1.0)
    221     Top layer defaults to vacuum (or air/any gas); can be substituted for some other substance
    222     Bottom layer default: infinitely thisck Silicon; can be substituted for some other substance
     214    '''Fills in default items for the REFD Models dictionary which are
     215    defined as follows for each layer:
     216   
     217    * Name: name of substance
     218    * Thick: thickness of layer in Angstroms (not present for top & bottom layers)
     219    * Rough: upper surface roughness for layer (not present for toplayer)
     220    * Penetration: mixing of layer substance into layer above-is this needed?
     221    * DenMul: multiplier for layer scattering density (default = 1.0)
     222       
     223    Top layer defaults to vacuum (or air/any gas); can be substituted for some other substance.
     224   
     225    Bottom layer default: infinitely thisck Silicon; can be substituted for some other substance.
    223226    '''
    224227    return {'Layers':[{'Name':'vacuum','DenMul':[1.0,False],},                                  #top layer
  • trunk/GSASIIsasd.py

    r2787 r2802  
    5151def SphereFF(Q,R,args=()):
    5252    ''' Compute hard sphere form factor - can use numpy arrays
    53     param float Q: Q value array (usually in A-1)
    54     param float R: sphere radius (Usually in A - must match Q-1 units)
    55     param array args: ignored
    56     returns float: form factors as array as needed
     53    :param float Q: Q value array (usually in A-1)
     54    :param float R: sphere radius (Usually in A - must match Q-1 units)
     55    :param array args: ignored
     56    :returns: form factors as array as needed (float)
    5757    '''
    5858    QR = Q[:,np.newaxis]*R
     
    6161def SphericalShellFF(Q,R,args=()):
    6262    ''' Compute spherical shell form factor - can use numpy arrays
    63     param float Q: Q value array (usually in A-1)
    64     param float R: sphere radius (Usually in A - must match Q-1 units)
    65     param array args: [float r]: controls the shell thickness: R_inner = min(r*R,R), R_outer = max(r*R,R)
    66     returns float: form factors as array as needed
     63    :param float Q: Q value array (usually in A-1)
     64    :param float R: sphere radius (Usually in A - must match Q-1 units)
     65    :param array args: [float r]: controls the shell thickness: R_inner = min(r*R,R), R_outer = max(r*R,R)
     66    :returns float: form factors as array as needed
     67   
    6768        Contributed by: L.A. Avakyan, Southern Federal University, Russia
    6869    '''
  • trunk/docs/source/GSASIIscripts.rst

    r2027 r2802  
    1414    :members:
    1515
     16.. automodule:: makeBat
     17    :members:
     18
    1619.. automodule:: unit_tests
    1720    :members:
  • trunk/docs/source/conf.py

    r2764 r2802  
    3636        class colourselect(MagicMock): pass
    3737        class resizewidget(MagicMock): pass
    38 
    39 sys.modules.update({'wx':wx()})
    40 sys.modules.update({'wx.aui':wx.aui()})
    41 sys.modules.update({'wx.html':wx.html()})
    42 sys.modules.update({'wx.grid':wx.grid()})
    43 sys.modules.update({'wx.lib':wx.lib()})
    44 sys.modules.update({'wx.wizard':wx.grid()})
    45 sys.modules.update({'wx.glcanvas':wx.lib()})
    46 sys.modules.update({'wx.lib.scrolledpanel':wx.lib.scrolledpanel()})
    47 sys.modules.update({'wx.lib.gridmovers':wx.lib.gridmovers()})
    48 sys.modules.update({'wx.lib.colourselect':wx.lib.gridmovers()})
    49 sys.modules.update({'wx.lib.resizewidget':wx.lib.resizewidget()})
     38        class mixins(MagicMock):
     39            class listctrl(MagicMock):
     40                ListCtrlAutoWidthMixin = object
     41                TextEditMixin = object
     42
     43sys.modules.update({'wx':wx(),
     44    'wx.aui':wx.aui(),
     45    'wx.html':wx.html(),
     46        'wx.grid':wx.grid(),
     47        'wx.lib':wx.lib(),
     48        'wx.wizard':wx.grid(),
     49        'wx.glcanvas':wx.lib(),
     50        'wx.lib.scrolledpanel':wx.lib.scrolledpanel(),
     51        'wx.lib.gridmovers':wx.lib.gridmovers(),
     52        'wx.lib.colourselect':wx.lib.gridmovers(),
     53        'wx.lib.resizewidget':wx.lib.resizewidget(),
     54        'wx.lib.mixins':wx.lib.mixins(),
     55        'wx.lib.mixins.listctrl':wx.lib.mixins.listctrl()})
     56wx.aui.AUI_NB_TOP = 0
     57wx.aui.AUI_NB_SCROLL_BUTTONS = 0
    5058
    5159class numpy(MagicMock):
     
    6876sys.modules.update({'scipy.special':scipy.optimize()})
    6977sys.modules.update({'scipy.misc':scipy.optimize()})
     78sys.modules.update({'scipy.signal':scipy.optimize()})
     79sys.modules.update({'scipy.cluster':scipy.optimize()})
     80sys.modules.update({'scipy.cluster.vq':scipy.optimize()})
    7081
    7182class OpenGL(MagicMock):
     
    8495MOCK_MODULES = [
    8596                'pypowder', 'pyspg', 'pytexture', 'polymask', 'fellipse',
    86                 'matplotlib', 'matplotlib.backends', 'matplotlib.backends.backend_wx',
    87                 'matplotlib.backends.backend_wxagg','pylab',
     97                'matplotlib', 'matplotlib.backends', 'matplotlib.backends.backend_wx',
     98                'matplotlib.colors',
     99                'matplotlib.backends.backend_wxagg','pylab','matplotlib.collections',
    88100                'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.mplot3d.axes3d',
     101                'winreg','unpack_cbf','h5py'
    89102                ]
    90103sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
  • trunk/docs/source/imports.rst

    r2087 r2802  
    223223    :synopsis: Reads phase information from a CIF
    224224
     225.. automodule:: G2phase_INS
     226    :members:
     227
     228
     229
    225230Powder Data Import Routines
    226231---------------------------------------------
     
    248253    :members:
    249254    :synopsis: Reads powder data from a CIF
     255
     256.. automodule:: G2pwd_BrukerRAW
     257    :members:
     258    :synopsis: Reads powder data from a Brucker .raw file
     259
     260.. automodule:: G2pwd_FP
     261    :members:
     262
     263.. automodule:: G2pwd_Panalytical
     264    :members:
     265
     266.. automodule:: G2pwd_csv
     267    :members:
     268
     269.. automodule:: G2pwd_rigaku
     270    :members:
     271
     272
    250273
    251274Single Crystal Data Import Routines
     
    315338.. automodule:: G2img_CheMin
    316339    :members:
     340
     341.. automodule:: G2img_CBF
     342    :members:
     343
     344.. automodule:: G2img_HDF5
     345    :members:
     346
     347PDF Import Routines
     348-----------------------------------------------------
     349PDF import routines are classes derived from
     350:class:`GSASIIIO.ImportPDFData`.
     351See :ref:`Writing a Import Routine<Import_Routines>` for general information on importers.
     352
     353The distributed routines are:
     354
     355.. automodule:: G2pdf_gr
     356    :members:
     357
     358Reflectometry Import Routines
     359-----------------------------------------------------
     360Reflectometry import routines are classes derived from
     361:class:`GSASIIIO.ImportReflectometryData`.
     362See :ref:`Writing a Import Routine<Import_Routines>` for general information on importers.
     363
     364The distributed routines are:
     365
     366.. automodule:: G2rfd_xye
     367    :members:
     368
     369
  • trunk/imports/G2img_CBF.py

    r2539 r2802  
    99'''
    1010*Module G2img_CBF: .cbf cif image file*
    11 --------------------------------------
     11---------------------------------------
    1212
    1313'''
  • trunk/imports/G2img_HDF5.py

    r2465 r2802  
    99'''
    1010*Module G2img_HDF5: summed HDF5 image file*
    11 ---------------------------------------
     11-------------------------------------------
    1212
    1313Reads all images found in a HDF5 file.
     
    2525class HDF5_Reader(G2IO.ImportImage):
    2626    '''Routine to read a HD5 image, typically from APS Sector 6.
    27     B. Frosik/SDM. Initial version.
    28                    Refactored.       
     27    B. Frosik/SDM.
    2928    '''
    3029    dsetlist = []
  • trunk/imports/G2pwd_FP.py

    r2738 r2802  
    99'''
    1010*Module G2pwd_FP: FullProf .dat data*
    11 ------------------------------------
     11-------------------------------------
    1212
    1313Routine to read in powder data from a FullProf .dat file
  • trunk/makeBat.py

    r2187 r2802  
     1'''
     2*makeBat: Create GSAS-II Batch File*
     3====================================
     4
     5This script creates a filen named ``RunGSASII.bat`` and a desktop shortcut to that file.
     6It registers the filetype .gpx so that the GSAS-II project files exhibit the
     7GSAS-II icon and so that double-clicking on them opens them in GSAS-II.
     8
     9Run this script with no arguments; the path to the ``GSASII.py`` file
     10is assumed to be the the same as the path to the ``makeBat.py`` file
     11and the path to Python is determined from the version of Python
     12used to run this script.
     13
     14'''
    115# creates Windows files to aid in running GSAS-II
    216#   creates RunGSASII.bat and a desktop shortcut to that file
     
    3044
    3145'''
    32 gsaspath = os.path.split(sys.argv[0])[0]
    33 if not gsaspath: gsaspath = os.path.curdir
    34 gsaspath = os.path.abspath(os.path.expanduser(gsaspath))
    35 G2script = os.path.join(gsaspath,'GSASII.py')
    36 G2bat = os.path.join(gsaspath,'RunGSASII.bat')
    37 G2icon = os.path.join(gsaspath,'gsas2.ico')
    38 pythonexe = os.path.realpath(sys.executable)
    39 # Bob reports a problem using pythonw.exe w/Canopy on Windows, so change that if used
    40 if pythonexe.lower().endswith('pythonw.exe'):
    41     print "  using python.exe rather than "+pythonexe
    42     pythonexe = os.path.join(os.path.split(pythonexe)[0],'python.exe')
    43     print "  now pythonexe="+pythonexe
    44 # create a GSAS-II script
    45 fp = open(os.path.join(G2bat),'w')
    46 fp.write("@REM created by run of bootstrap.py on {:%d %b %Y %H:%M}\n".format(
    47     datetime.datetime.now()))
    48 pexe = pythonexe
    49 if ' ' in pythonexe: pexe = '"'+pythonexe+'"'
    50 G2s = G2script
    51 if ' ' in G2s: G2s = '"'+G2script+'"'
    52 fp.write(Script.format(pexe,G2s))
    53 fp.close()
    54 print '\nCreated GSAS-II batch file RunGSASII.bat in '+gsaspath
    5546
    56 # Associate a script and icon with .gpx files
    57 #gpxkey = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, '.gpx')
    58 gpxkey = winreg.CreateKey(winreg.HKEY_CURRENT_USER,r'Software\CLASSES\.gpx')
    59 winreg.SetValue(gpxkey, None, winreg.REG_SZ, 'GSAS-II.project')
    60 winreg.CloseKey(gpxkey)
    61 gpxkey = winreg.CreateKey(winreg.HKEY_CURRENT_USER,r'Software\CLASSES\GSAS-II.project')
    62 winreg.SetValue(gpxkey, None, winreg.REG_SZ, 'GSAS-II project')
    63 iconkey = winreg.CreateKey(gpxkey, 'DefaultIcon')
    64 winreg.SetValue(iconkey, None, winreg.REG_SZ, G2icon)
    65 openkey = winreg.CreateKey(gpxkey, r'shell\open\command')
    66 winreg.SetValue(openkey, None, winreg.REG_SZ, G2bat+' "%1"')
    67 winreg.CloseKey(iconkey)
    68 winreg.CloseKey(openkey)
    69 winreg.CloseKey(gpxkey)
    70 print 'Assigned icon and batch file to .gpx files'
     47if __name__ == '__main__':
     48    gsaspath = os.path.split(sys.argv[0])[0]
     49    if not gsaspath: gsaspath = os.path.curdir
     50    gsaspath = os.path.abspath(os.path.expanduser(gsaspath))
     51    G2script = os.path.join(gsaspath,'GSASII.py')
     52    G2bat = os.path.join(gsaspath,'RunGSASII.bat')
     53    G2icon = os.path.join(gsaspath,'gsas2.ico')
     54    pythonexe = os.path.realpath(sys.executable)
     55    # Bob reports a problem using pythonw.exe w/Canopy on Windows, so change that if used
     56    if pythonexe.lower().endswith('pythonw.exe'):
     57        print "  using python.exe rather than "+pythonexe
     58        pythonexe = os.path.join(os.path.split(pythonexe)[0],'python.exe')
     59        print "  now pythonexe="+pythonexe
     60    # create a GSAS-II script
     61    fp = open(os.path.join(G2bat),'w')
     62    fp.write("@REM created by run of bootstrap.py on {:%d %b %Y %H:%M}\n".format(
     63        datetime.datetime.now()))
     64    pexe = pythonexe
     65    if ' ' in pythonexe: pexe = '"'+pythonexe+'"'
     66    G2s = G2script
     67    if ' ' in G2s: G2s = '"'+G2script+'"'
     68    fp.write(Script.format(pexe,G2s))
     69    fp.close()
     70    print '\nCreated GSAS-II batch file RunGSASII.bat in '+gsaspath
    7171
    72 try:
    73     import win32com.shell.shell, win32com.shell.shellcon
    74     win32com.shell.shell.SHChangeNotify(
    75         win32com.shell.shellcon.SHCNE_ASSOCCHANGED, 0, None, None)
    76 except ImportError:
    77     print 'Module pywin32 not present, login again to see file types properly'
    78 except:
    79     print 'Unexpected error on explorer refresh. Please report:'
    80     import traceback
    81     print traceback.format_exc()
     72    # Associate a script and icon with .gpx files
     73    #gpxkey = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, '.gpx')
     74    gpxkey = winreg.CreateKey(winreg.HKEY_CURRENT_USER,r'Software\CLASSES\.gpx')
     75    winreg.SetValue(gpxkey, None, winreg.REG_SZ, 'GSAS-II.project')
     76    winreg.CloseKey(gpxkey)
     77    gpxkey = winreg.CreateKey(winreg.HKEY_CURRENT_USER,r'Software\CLASSES\GSAS-II.project')
     78    winreg.SetValue(gpxkey, None, winreg.REG_SZ, 'GSAS-II project')
     79    iconkey = winreg.CreateKey(gpxkey, 'DefaultIcon')
     80    winreg.SetValue(iconkey, None, winreg.REG_SZ, G2icon)
     81    openkey = winreg.CreateKey(gpxkey, r'shell\open\command')
     82    winreg.SetValue(openkey, None, winreg.REG_SZ, G2bat+' "%1"')
     83    winreg.CloseKey(iconkey)
     84    winreg.CloseKey(openkey)
     85    winreg.CloseKey(gpxkey)
     86    print 'Assigned icon and batch file to .gpx files'
    8287
    83 # make a desktop shortcut to GSAS-II
    84 try:
    85     import win32com.shell.shell, win32com.shell.shellcon, win32com.client
    86     desktop = win32com.shell.shell.SHGetFolderPath(
    87         0, win32com.shell.shellcon.CSIDL_DESKTOP, None, 0)
    88     shortcut = os.path.join(desktop, "GSAS-II.lnk")
    89     shell = win32com.client.Dispatch('WScript.Shell')
    90     shobj = shell.CreateShortCut(shortcut)
    91     shobj.Targetpath = G2bat
    92     #shobj.WorkingDirectory = wDir # could specify a default project location here
    93     shobj.IconLocation = G2icon
    94     shobj.save()
    95     print 'Created shortcut to start GSAS-II on desktop'
    96 except ImportError:
    97     print 'Module pywin32 not present, will not make desktop shortcut'
    98 except:
    99     print 'Unexpected error making desktop shortcut. Please report:'
    100     import traceback
    101     print traceback.format_exc()
     88    try:
     89        import win32com.shell.shell, win32com.shell.shellcon
     90        win32com.shell.shell.SHChangeNotify(
     91            win32com.shell.shellcon.SHCNE_ASSOCCHANGED, 0, None, None)
     92    except ImportError:
     93        print 'Module pywin32 not present, login again to see file types properly'
     94    except:
     95        print 'Unexpected error on explorer refresh. Please report:'
     96        import traceback
     97        print traceback.format_exc()
     98
     99    # make a desktop shortcut to GSAS-II
     100    try:
     101        import win32com.shell.shell, win32com.shell.shellcon, win32com.client
     102        desktop = win32com.shell.shell.SHGetFolderPath(
     103            0, win32com.shell.shellcon.CSIDL_DESKTOP, None, 0)
     104        shortcut = os.path.join(desktop, "GSAS-II.lnk")
     105        shell = win32com.client.Dispatch('WScript.Shell')
     106        shobj = shell.CreateShortCut(shortcut)
     107        shobj.Targetpath = G2bat
     108        #shobj.WorkingDirectory = wDir # could specify a default project location here
     109        shobj.IconLocation = G2icon
     110        shobj.save()
     111        print 'Created shortcut to start GSAS-II on desktop'
     112    except ImportError:
     113        print 'Module pywin32 not present, will not make desktop shortcut'
     114    except:
     115        print 'Unexpected error making desktop shortcut. Please report:'
     116        import traceback
     117        print traceback.format_exc()
    102118   
Note: See TracChangeset for help on using the changeset viewer.