fpdb/pyfpdb/Options.py
Eric Blade 64d9a3582b No longer mess with sys.argv (messing with system variables is a bad thing, right), use argv to determine pathname of executeable as sys.path[0] is just the first component of the path. also all database errors except MySQL reporting "Access Denied" should now crash FPDB, so someone can fill those into Exceptions, and into the fpdb_db and the fpdb files.
Process: get crash info, add exception info to Exceptions.py, catch generic database exception in fpdb_db.py (around the connect line), throw correct Fpdb exception, then catch it in fpdb.py and do the appropriate thing on the GUI end.
2009-11-22 00:00:23 -05:00

49 lines
1.9 KiB
Python

#!/usr/bin/python
#Copyright 2008 Ray E. Barker
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as published by
#the Free Software Foundation, version 3 of the License.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in
#agpl-3.0.txt in the docs folder of the package.
import os
import sys
from optparse import OptionParser
def fpdb_options():
"""Process command line options for fpdb and HUD_main."""
parser = OptionParser()
parser.add_option("-x", "--errorsToConsole",
action="store_true",
help="If passed error output will go to the console rather than .")
parser.add_option("-d", "--databaseName",
dest="dbname", default="fpdb",
help="Overrides the default database name")
parser.add_option("-c", "--configFile",
dest="config", default=None,
help="Specifies a configuration file.")
parser.add_option("-r", "--rerunPython",
action="store_true",
help="Indicates program was restarted with a different path (only allowed once).")
(options, argv) = parser.parse_args()
return (options, argv)
if __name__== "__main__":
(options, sys.argv) = fpdb_options()
print "errorsToConsole =", options.errorsToConsole
print "database name =", options.dbname
print "config file =", options.config
print "press enter to end"
sys.stdin.readline()