annotate run_pasta.py @ 0:7ba9469800b9 draft

Uploaded
author greg
date Thu, 08 Jun 2017 12:46:20 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7ba9469800b9 Uploaded
greg
parents:
diff changeset
1 #! /usr/bin/env python
7ba9469800b9 Uploaded
greg
parents:
diff changeset
2
7ba9469800b9 Uploaded
greg
parents:
diff changeset
3 """Main script of PASTA in command-line mode - this simply invokes the main
7ba9469800b9 Uploaded
greg
parents:
diff changeset
4 function found in pasta/mainpasta.py
7ba9469800b9 Uploaded
greg
parents:
diff changeset
5 """
7ba9469800b9 Uploaded
greg
parents:
diff changeset
6
7ba9469800b9 Uploaded
greg
parents:
diff changeset
7 # This file is part of PASTA which is forked from SATe
7ba9469800b9 Uploaded
greg
parents:
diff changeset
8
7ba9469800b9 Uploaded
greg
parents:
diff changeset
9 # PASTA like SATe is free software: you can redistribute it and/or modify
7ba9469800b9 Uploaded
greg
parents:
diff changeset
10 # it under the terms of the GNU General Public License as published by
7ba9469800b9 Uploaded
greg
parents:
diff changeset
11 # the Free Software Foundation, either version 3 of the License, or
7ba9469800b9 Uploaded
greg
parents:
diff changeset
12 # (at your option) any later version.
7ba9469800b9 Uploaded
greg
parents:
diff changeset
13 #
7ba9469800b9 Uploaded
greg
parents:
diff changeset
14 # This program is distributed in the hope that it will be useful,
7ba9469800b9 Uploaded
greg
parents:
diff changeset
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7ba9469800b9 Uploaded
greg
parents:
diff changeset
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7ba9469800b9 Uploaded
greg
parents:
diff changeset
17 # GNU General Public License for more details.
7ba9469800b9 Uploaded
greg
parents:
diff changeset
18 #
7ba9469800b9 Uploaded
greg
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License
7ba9469800b9 Uploaded
greg
parents:
diff changeset
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
7ba9469800b9 Uploaded
greg
parents:
diff changeset
21
7ba9469800b9 Uploaded
greg
parents:
diff changeset
22 # Jiaye Yu and Mark Holder, University of Kansas
7ba9469800b9 Uploaded
greg
parents:
diff changeset
23
7ba9469800b9 Uploaded
greg
parents:
diff changeset
24 if __name__ == "__main__":
7ba9469800b9 Uploaded
greg
parents:
diff changeset
25 import os
7ba9469800b9 Uploaded
greg
parents:
diff changeset
26 import sys
7ba9469800b9 Uploaded
greg
parents:
diff changeset
27 from pasta.mainpasta import pasta_main
7ba9469800b9 Uploaded
greg
parents:
diff changeset
28 from pasta import MESSENGER
7ba9469800b9 Uploaded
greg
parents:
diff changeset
29 sys.setrecursionlimit(100000)
7ba9469800b9 Uploaded
greg
parents:
diff changeset
30 _PASTA_DEBUG = os.environ.get('PASTA_DEBUG')
7ba9469800b9 Uploaded
greg
parents:
diff changeset
31 _DEVELOPER = _PASTA_DEBUG and _PASTA_DEBUG != '0'
7ba9469800b9 Uploaded
greg
parents:
diff changeset
32
7ba9469800b9 Uploaded
greg
parents:
diff changeset
33 if not _DEVELOPER:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
34 _PASTA_DEVELOPER = os.environ.get('PASTA_DEVELOPER')
7ba9469800b9 Uploaded
greg
parents:
diff changeset
35 _DEVELOPER = _PASTA_DEVELOPER and _PASTA_DEVELOPER != '0'
7ba9469800b9 Uploaded
greg
parents:
diff changeset
36 try:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
37 rc, temp_dir, temp_fs = pasta_main()
7ba9469800b9 Uploaded
greg
parents:
diff changeset
38 if not rc:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
39 raise ValueError("Unknown PASTA execution error")
7ba9469800b9 Uploaded
greg
parents:
diff changeset
40 if (temp_dir is not None) and (os.path.exists(temp_dir)):
7ba9469800b9 Uploaded
greg
parents:
diff changeset
41 MESSENGER.send_info("Note that temporary files from the run have not been deleted, they can be found in:\n '%s'\n" % temp_dir)
7ba9469800b9 Uploaded
greg
parents:
diff changeset
42 if sys.platform.lower().startswith('darwin') and ("'" not in temp_dir):
7ba9469800b9 Uploaded
greg
parents:
diff changeset
43 MESSENGER.send_info('''
7ba9469800b9 Uploaded
greg
parents:
diff changeset
44 If you cannot see this directory in the Finder application, you may want to use
7ba9469800b9 Uploaded
greg
parents:
diff changeset
45 the 'open' command executed from a Terminal. You can do this by launching the
7ba9469800b9 Uploaded
greg
parents:
diff changeset
46 /Applications/Utilities/Terminal program and then typing
7ba9469800b9 Uploaded
greg
parents:
diff changeset
47
7ba9469800b9 Uploaded
greg
parents:
diff changeset
48 open '%s'
7ba9469800b9 Uploaded
greg
parents:
diff changeset
49
7ba9469800b9 Uploaded
greg
parents:
diff changeset
50 followed by a return at the prompt. If the argument to the open command is a
7ba9469800b9 Uploaded
greg
parents:
diff changeset
51 directory, then it should open a Finder window in the directory (even if that
7ba9469800b9 Uploaded
greg
parents:
diff changeset
52 directory is hidden by default).
7ba9469800b9 Uploaded
greg
parents:
diff changeset
53 ''' % temp_dir)
7ba9469800b9 Uploaded
greg
parents:
diff changeset
54 except Exception as x:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
55 if _DEVELOPER:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
56 raise
7ba9469800b9 Uploaded
greg
parents:
diff changeset
57 message = "PASTA is exiting because of an error:\n%s " % str(x)
7ba9469800b9 Uploaded
greg
parents:
diff changeset
58 try:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
59 from pasta import MESSENGER
7ba9469800b9 Uploaded
greg
parents:
diff changeset
60 MESSENGER.send_error(message)
7ba9469800b9 Uploaded
greg
parents:
diff changeset
61 except:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
62 sys.stderr.write(message)
7ba9469800b9 Uploaded
greg
parents:
diff changeset
63 sys.exit(1)