Use debian 2.7 only
[fpbd-bostik.git] / pyfpdb / windows_make_bats.py
blob7667b4b563c959cb6aacf4c57ab48aefc459032c
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 #Copyright 2009-2011 Carl Gherardi
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 # create .bat scripts in windows to try out different gtk dirs
20 import L10n
21 _ = L10n.get_translation()
23 try:
25 import os
26 import sys
27 import re
29 if os.name != 'nt':
30 print _("This script is only for Windows.")
31 exit()
33 dirs = re.split(os.pathsep, os.environ['PATH'])
34 # remove any trailing / or \ chars from dirs:
35 dirs = [re.sub('[\\/]$','',p) for p in dirs]
36 # remove any dirs containing 'python' apart from those ending in 'python25', 'python26' or 'python':
37 dirs = [p for p in dirs if not re.search('python', p, re.I) or re.search('python25$', p, re.I) or re.search('python26$', p, re.I)]
38 # find gtk dirs:
39 gtkdirs = [p for p in dirs if re.search('gtk', p, re.I)]
41 lines = [ '@echo off\n\n'
42 , '<path goes here>'
43 , 'python fpdb.py\n\n'
44 , 'pause\n\n'
46 if gtkdirs:
47 i = 1
48 for gpath in gtkdirs: # enumerate converts the \\ into \
49 tmpdirs = [p for p in dirs if not re.search('gtk', p, re.I) or p == gpath]
50 tmppath = ";".join(tmpdirs)
51 lines[1] = 'PATH=' + tmppath + '\n\n'
52 bat = open('run_fpdb'+str(i)+'.bat', 'w')
53 bat.writelines(lines)
54 bat.close()
55 i = i + 1
56 else:
57 print _("No gtk directories found in your path.") + " " + _("Install gtk or edit the path manually.")
59 except SystemExit:
60 pass
62 except:
63 print "Error:", str(sys.exc_info())
64 pass
66 # sys.stdin.readline()