1 | #!/usr/bin/env python |
---|
2 | import os, stat, sys, platform, subprocess |
---|
3 | home = 'https://subversion.xor.aps.anl.gov/EXPGUI/' |
---|
4 | |
---|
5 | print sys.argv |
---|
6 | gsaspath = os.path.split(sys.argv[0])[0] |
---|
7 | gsaspath = os.path.abspath(os.path.expanduser(gsaspath)) |
---|
8 | |
---|
9 | print 'GSAS is being bootstrapped from repository to '+gsaspath |
---|
10 | |
---|
11 | print 'Determining system type...', |
---|
12 | if sys.platform.startswith('linux') and platform.processor().endswith('86'): |
---|
13 | repos = 'linux' |
---|
14 | elif sys.platform == "darwin" and platform.processor() == 'i386': |
---|
15 | repos = 'osxi86' |
---|
16 | else: |
---|
17 | raise Exception('Undefined system type') |
---|
18 | print 'OK' |
---|
19 | |
---|
20 | print 'Checking for subversion...', |
---|
21 | try: |
---|
22 | #p = subprocess.call(['svn','status'],stdout=subprocess.PIPE) |
---|
23 | p = subprocess.Popen(['svn','help'],stdout=subprocess.PIPE) |
---|
24 | except: |
---|
25 | raise Exception('Subversion (svn) not found') |
---|
26 | res = p.stdout.read() |
---|
27 | print 'OK' |
---|
28 | |
---|
29 | cmds = ( |
---|
30 | (['svn', 'co', home+ 'gsas/all', gsaspath],'loading GSAS common'), |
---|
31 | (['svn', 'switch', home+ 'trunk/', gsaspath+'/expgui'],'loading EXPGUI'), |
---|
32 | (['svn', 'switch', home+ 'gsas/' + repos+ '/exe/', gsaspath+'/exe'],'loading GSAS programs'), |
---|
33 | (['svn', 'switch', home+ 'gsas/' + repos+ '/pgl/', gsaspath+'/pgl'],'loading PGPLOT files'), |
---|
34 | ) |
---|
35 | |
---|
36 | for cmd,msg in cmds: |
---|
37 | print 70*'*' |
---|
38 | print msg + ' from ' + cmd[2] |
---|
39 | for item in cmd: print item, |
---|
40 | print "" |
---|
41 | p = subprocess.call(cmd) |
---|
42 | |
---|
43 | if sys.platform.startswith('linux') and platform.processor().endswith('86'): |
---|
44 | os.chmod(gsaspath + "/expgui/expgui", |
---|
45 | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH) |
---|
46 | open(os.path.expanduser('~/Desktop/EXPGUI.desktop'),'w').write(''' |
---|
47 | [Desktop Entry] |
---|
48 | Encoding=UTF-8 |
---|
49 | Version=1.0 |
---|
50 | Type=Application |
---|
51 | Terminal=false |
---|
52 | Exec=%s/expgui/expgui |
---|
53 | Name=EXPGUI |
---|
54 | Icon=%s/EXPGUI.png |
---|
55 | ''' % (gsaspath,gsaspath)) |
---|
56 | os.chmod(os.path.expanduser('~/Desktop/EXPGUI.desktop'), |
---|
57 | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH) |
---|
58 | open(os.path.expanduser('~/Desktop/GSAS.desktop'),'w').write(''' |
---|
59 | [Desktop Entry] |
---|
60 | Encoding=UTF-8 |
---|
61 | Version=1.0 |
---|
62 | Type=Application |
---|
63 | Terminal=true |
---|
64 | Exec=%s/GSAS |
---|
65 | Name=GSAS |
---|
66 | Icon=%s/GSAS.png |
---|
67 | ''' % (gsaspath,gsaspath)) |
---|
68 | os.chmod(os.path.expanduser('~/Desktop/GSAS.desktop'), |
---|
69 | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH) |
---|