forked from sfepy/sfepy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisfepy
executable file
·102 lines (78 loc) · 3.29 KB
/
isfepy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/python
"""
Python shell for SfePy.
This is just a normal Python shell (IPython shell if you have the
IPython package installed), that executes the following commands
for the user:
>>> from sfepy.base.base import *
>>> from sfepy.fem import *
>>> from sfepy.applications import solve_pde
>>> from sfepy.postprocess import Viewer
So starting 'isfepy' is roughly (*) equivalent to starting Python (or
IPython) and executing the above commands by hand. It is intended for easy
and quick experimentation with SfePy.
(*) Advantages of using isfepy instead of IPython directly are:
- all SfePy messages are logged into ~/.sfepy/isfepy.log;
- it is possible to silence the messages printed on screen.
COMMAND LINE OPTIONS
--------------------
-c CONSOLE, --console=CONSOLE
Use the specified Python or IPython shell as console backend instead
of the default one (IPython if present or Python otherwise), e.g.:
isfepy -c python
-q, --quiet
Print only Python's and SfePy's versions to stdout at startup.
-s, --silent
Silence the messages printed to screen.
-- IPython's options
Additionally you can pass command line options directly to IPython
interpreter (standard Python shell is not supported). However you
need to add '--' separator between two types of options. To run
SfePy without startup banner and colors, for example, issue:
isfepy -q -- -colors NoColor
isfepy -q -- --colors NoColor (for ipython >= 0.11)
For non-blocking matplotlib plots in ipython >= 0.11 use:
isfepy -- --pylab=wx
"""
from optparse import OptionParser
import sfepy
usage = 'usage: isfepy [options] -- [ipython options]'
help = {
'console' :
'select type of interactive session: ipython | python [default: %default]',
'quiet' :
'print only version information at startup',
'silent' :
'silence the messages printed on screen',
'no_viewer' :
'do not attempt to import Viewer',
'no_wx' :
'do not try using the threaded Wx ipython shell',
}
def main():
parser = OptionParser(usage=usage, version="%prog " + sfepy.__version__)
parser.add_option('-c', '--console', dest='console', action='store',
default='ipython', choices=['ipython', 'python'],
help=help['console'])
parser.add_option('-q', '--quiet', dest='quiet', action='store_true',
default=False, help=help['quiet'])
parser.add_option('-s', '--silent', dest='silent', action='store_true',
default=False, help=help['silent'])
parser.add_option('', '--no-viewer', dest='is_viewer', action='store_false',
default=True, help=help['no_viewer'])
parser.add_option('', '--no-wx', dest='is_wx', action='store_false',
default=True, help=help['no_wx'])
options, ipy_args = parser.parse_args()
session = options.console
ipython = session == 'ipython'
args = {
'argv' : ipy_args,
'quiet' : options.quiet,
'silent' : options.silent,
'is_viewer' : options.is_viewer,
'is_wx' : options.is_wx,
}
from sfepy.interactive import init_session
init_session(ipython, **args)
if __name__ == "__main__":
main()