2 # -*- coding: utf-8 -*-
4 # Copyright 2011, Gimick (bbtgaf@googlemail.com)
5 #This program is free software: you can redistribute it and/or modify
6 #it under the terms of the GNU Affero General Public License as published by
7 #the Free Software Foundation, version 3 of the License.
9 #This program is distributed in the hope that it will be useful,
10 #but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 #GNU General Public License for more details.
14 #You should have received a copy of the GNU Affero General Public License
15 #along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #In the "official" distribution you can find the license in agpl-3.0.txt.
18 ########################################################################
24 global_modules_to_test
= ["gobject",
34 windows_modules_to_test
= ["win32gui",
42 linux_modules_to_test
= []
43 mac_modules_to_test
= []
44 posix_modules_to_test
= []
46 def win_output(message
):
50 win
.geometry("600x400")
51 listbox
= Listbox(win
)
53 listbox
.insert(END
,item
)
54 listbox
.pack(fill
=BOTH
, expand
=YES
)
57 def try_import(modulename
):
60 module
= __import__(modulename
)
63 failure( _('File not found')+ ": " +modulename
)
64 if modulename
in ["cairo", "gobject", "pygtk"]:
65 failure(_("Unable to load PyGTK modules required for GUI. Please install PyCairo, PyGObject, and PyGTK from www.pygtk.org."))
66 if modulename
in ["win32console"]:
67 failure (_("We appear to be running in Windows, but the Windows Python Extensions are not loading. Please install the PYWIN32 package from http://sourceforge.net/projects/pywin32/"))
70 if modulename
== "pygtk":
76 failure("pygtk 2.0 " + _('File not found'))
79 if modulename
== "matplotlib":
82 success("matplotlib/gtk")
85 failure("matplotlib/gtk")
93 success_list
.append(message
)
97 print _("Error:"), message
98 failure_list
.append(message
)
100 #=====================================================================
103 # check for gross failures first, no translation on the first
104 # two messages because L10n not guaranteed to be available
107 from Tkinter
import *
112 failure("python failure - could not import sys module")
113 win_output(failure_list
)
117 try_import("Charset")
119 failure("fpdb must be installed in an English path")
120 win_output(failure_list
)
125 if sys
.argv
[1] == "-v":
131 _
= L10n
.get_translation()
133 config
= Configuration
.Config()
135 if config
.python_version
not in("2.6", "2.7"):
136 failure(_("\npython 2.6-2.7 not found, please install python 2.6 or 2.7 for fpdb\n"))
139 # next, check for individual modules existing
142 for i
in global_modules_to_test
:
144 if config
.os_family
in ("XP", "Win7"):
145 for i
in windows_modules_to_test
:
147 elif config
.os_family
== "Linux":
148 for i
in linux_modules_to_test
:
150 elif config
.os_family
== "Mac":
151 for i
in mac_modules_to_test
:
154 for i
in posix_modules_to_test
:
158 # finished, work out how to exit
161 if len(failure_list
):
162 win_output(failure_list
)
164 if config
.install_method
== "exe":
165 if len(failure_list
):
170 if len(failure_list
):
171 if config
.os_family
in ("XP", "Win7"):
174 sys
.exit(failure_list
)
177 os
.chdir(os
.path
.join(config
.fpdb_program_path
, u
"pyfpdb"))
179 if config
.os_family
in ("XP", "Win7"):
180 os
.execvpe('pythonw.exe', list(('pythonw.exe', 'fpdb.pyw', '-r'))+sys
.argv
[1:], os
.environ
)
182 os
.execvpe('python', list(('python', 'fpdb.pyw', '-r'))+sys
.argv
[1:], os
.environ
)
185 # DO NOT INSERT ANY LINES BELOW HERE
186 # os.execvpe above stops transfers control to fpdb.pyw immediately