annotate parpg.py @ 16:f4f3c785b0b1 tip

Added a parpg-path parameter to the run script.
author Beliar <KarstenBock@gmx.net>
date Tue, 20 Mar 2012 13:55:41 +0100
parents 21714c459078
children
rev   line source
6
0897c89da4fe Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 5
diff changeset
1 #!/usr/bin/env python
4
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
2 # This program is free software: you can redistribute it and/or modify
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
3 # it under the terms of the GNU General Public License as published by
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
5 # (at your option) any later version.
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
6
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
7 # This program is distributed in the hope that it will be useful,
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
10 # GNU General Public License for more details.
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
11
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
12 # You should have received a copy of the GNU General Public License
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
14
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
15 #TODO: Modularize this script
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
16 import sys
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
17 from optparse import OptionParser
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
18 from os import path
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
19
12
21714c459078 Added command line option to manually set a fife path.
Beliar <KarstenBock@gmx.net>
parents: 6
diff changeset
20 usage = ('usage: %prog [options] '
4
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
21 'Example: python %prog .')
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
22
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
23 parser = OptionParser(description='PARPG Launcher Script', usage=usage)
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
24 parser.add_option('-f', '--logfile',
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
25 help='Name of log file to save to')
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
26 parser.add_option('-l', '--loglevel', default='critical',
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
27 help='desired output level for log file')
12
21714c459078 Added command line option to manually set a fife path.
Beliar <KarstenBock@gmx.net>
parents: 6
diff changeset
28 parser.add_option('-p', '--fife-path',
21714c459078 Added command line option to manually set a fife path.
Beliar <KarstenBock@gmx.net>
parents: 6
diff changeset
29 help='Path to the fife module')
16
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
30 parser.add_option('-m', '--parpg-path',
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
31 help='Path to the parpg module')
4
6ad756581ef1 Added parpg.py and a default configuration.
KarstenBock@gmx.net
parents:
diff changeset
32
16
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
33 opts, args = parser.parse_args()
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
34
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
35 try:
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
36 old_path = sys.path
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
37 if opts.parpg_path:
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
38 sys.path = [opts.parpg_path]
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
39 import parpg
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
40 except ImportError:
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
41 print("Could not import parpg module. Please install parpg or set the --parpg-path command line value")
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
42 parser.print_help()
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
43 sys.exit(1)
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
44 finally:
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
45 sys.path = old_path
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
46
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
47
f4f3c785b0b1 Added a parpg-path parameter to the run script.
Beliar <KarstenBock@gmx.net>
parents: 12
diff changeset
48 from parpg.main import main
12
21714c459078 Added command line option to manually set a fife path.
Beliar <KarstenBock@gmx.net>
parents: 6
diff changeset
49 main(parser)