Changeset 669 for install


Ignore:
Timestamp:
Jun 30, 2012 8:37:47 PM (11 years ago)
Author:
toby
Message:

Revise GSAS-II Mac app to run in terminal

File:
1 edited

Legend:

Unmodified
Added
Removed
  • install/bootstrap.py

    r333 r669  
    22import os, stat, sys, platform, subprocess
    33home = 'https://subversion.xor.aps.anl.gov/pyGSAS/'
     4print 70*'*'
     5print 'Checking python packages...',
     6missing = []
     7for pkg in ['numpy','scipy','matplotlib','wx']:
     8    try:
     9        exec('import '+pkg)
     10    except:
     11        missing.append(pkg)
    412
    5 print sys.argv
     13if missing:
     14    print """Sorry, this version of Python cannot be used
     15for GSAS-II. It is missing the following package(s):
     16\t""",
     17    for pkg in missing: print " ",pkg,
     18    print
     19    print "We suggest installing the EPDfree package at\nhttp://www.enthought.com/products/epd_free.php/"
     20    sys.exit()
     21
    622gsaspath = os.path.split(sys.argv[0])[0]
    723gsaspath = os.path.abspath(os.path.expanduser(gsaspath))
     
    1733print 'OK'
    1834
    19 print 'GSAS-II is being bootstrapped from repository\n',home,'\nto '+gsaspath
     35print 'GSAS-II is being bootstrapped from repository\n\t',home,'\nto '+gsaspath
    2036
    2137print 'Determining system type...',
     
    5672    script = '''
    5773(*   GSAS-II AppleScript by B. Toby (brian.toby@anl.gov)
    58          It can launch GSAS-II by double clicking or by dropping a data file or folder over that app.
    59          thanks to F. Farges; farges@univ-mlv.fr for showing me how to do much of this
     74         It can launch GSAS-II by double clicking or by dropping a data file
     75         or folder over the app.
     76         It runs GSAS-II in a terminal window.
     77         
     78         Thanks to F. Farges (farges@univ-mlv.fr) for many applescript tricks
    6079*)
    6180
     
    7796                if (file appwithpath exists) then
    7897                else
    79                         display dialog "Error: file " & appwithpath & " not found. This AppleScript must be run from a directory containing the GSAS-II executable. Did you move it?" with icon caution buttons {"Quit"}
     98                        display dialog "Error: file " & appwithpath & " not found. This AppleScript must be run from a directory containing the GSAS-II python code. Did you move it?" with icon caution buttons {"Quit"}
    8099                        return
    81100                end if
     
    92111*)
    93112on run
    94         set python to "%s"
     113        set python to "/Library/Frameworks/Python.framework/Versions/7.1/Resources/Python.app/Contents/MacOS/Python"
    95114        set myPath to (path to me)
    96115        set ParentPath to GetParentPath(myPath)
     
    98117        TestFilePresent(appwithpath)
    99118        set posixapp to quoted form of the POSIX path of appwithpath
    100         set results to do shell script python & " " & posixapp & " > ~/GSASIIerrors 2>&1  &"
     119        tell application "Terminal"
     120                activate
     121                do script python & " " & posixapp & "; exit"
     122        end tell
    101123end run
    102124
     
    115137on open names
    116138       
    117         set python to "%s"
     139        set python to "/Library/Frameworks/Python.framework/Versions/7.1/Resources/Python.app/Contents/MacOS/Python"
    118140        set myPath to (path to me)
    119141        set ParentPath to GetParentPath(myPath)
     
    127149                        set myfile to choose file default location filename with prompt "Select a GSAS-II input file" multiple selections allowed no
    128150                        set myfile to the quoted form of the POSIX path of myfile
    129                         set results to do shell script python & " " & posixapp & " " & myfile & " > ~/GSASIIerrors 2>&1  &"
     151                        tell application "Terminal"
     152                                activate
     153                                do script python & " " & posixapp & " " & myfile & "; exit"
     154                        end tell
    130155                else
    131156                        (* if this is an input file, open it *)
    132157                        set filename to the quoted form of the POSIX path of filename
    133                         set results to do shell script python & " " & posixapp & " " & filename & " > ~/GSASIIerrors 2>&1  &"
     158                        tell application "Terminal"
     159                                activate
     160                                do script python & " " & posixapp & " " & filename & "; exit"
     161                        end tell
    134162                end if
    135163        end repeat
     
    142170    p.communicate()
    143171    if os.path.exists('GSAS2.rsrc'):
    144         print "Note: ignore the -d warning from osacompile"
     172        print "Note: ignore the previous -d warning from osacompile"
    145173        p = subprocess.call(['/Developer/Tools/Rez','-append','GSAS2.rsrc','-o',app + "/Icon\r"])
    146174        p = subprocess.call(['/Developer/Tools/SetFile','-a','C',app])
Note: See TracChangeset for help on using the changeset viewer.