-
Notifications
You must be signed in to change notification settings - Fork 27
/
gnofract4d
executable file
·93 lines (78 loc) · 2.27 KB
/
gnofract4d
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
#!/usr/bin/env python3
# the main program. Relies on fract4d libs to do the real work
# python stdlib
import sys
import os
# gettext
import gettext
os.environ.setdefault('LANG', 'en')
if os.path.isdir('po'):
gettext.install('gnofract4d','po')
else:
gettext.install('gnofract4d')
try:
# nogui modules
from fract4d import fractconfig, fractmain
from fract4d.options import Arguments
except ImportError as err:
print((_('''
Can't import a required module.
If you haven't set up Gnofract 4D yet, run './setup.py build'
Error was: '%s' ''') % err))
sys.exit(1)
def main(args):
# saved options
userConfig = fractconfig.userConfig()
# command line options
opts = Arguments().parse_args(args)
try:
if opts.nogui:
plainmain(userConfig, opts)
else:
gtkmain(userConfig, opts)
except Exception as err:
print("A fatal error occurred:\n\t%s\n\n" % str(err))
raise
def gtkmain(userConfig, options):
# GTK+
import gi
gi.require_version('Gtk', '3.0')
try:
from gi.repository import Gtk
except ImportError as err:
print(_("Can't find Gtk. You need to install it before you can run Gnofract 4D."))
sys.exit(1)
try:
# GUI module
from fract4dgui import main_window
except ImportError as err:
print(_('''
Can't import a required module.
If you haven't set up Gnofract 4D yet, run './setup.py build'
Error was: '%s' ''') % err)
sys.exit(1)
mainWindow = main_window.MainWindow(userConfig)
mainWindow.apply_options(options)
if mainWindow.f.thaw():
gi.require_version('GLib', '2.0')
from gi.repository import GLib
GLib.idle_add(mainWindow.on_fractal_change)
Gtk.main()
def plainmain(userConfig, options):
t = fractmain.T(userConfig)
t.run(options)
def main_n(n):
for i in range(n):
main(sys.argv[1:])
if __name__ == '__main__':
if os.environ.get("DO_GF4D_PROFILE"):
import cProfile
import pstats
prof = cProfile.Profile()
prof.runcall(main_n, 5)
stats = pstats.Stats(prof)
stats.sort_stats("cumulative")
stats.dump_stats("gf4d.prof")
stats.print_stats()
else:
main(sys.argv[1:])