Add -c config cl option. Fpdb passes cl options to HUD.
This commit is contained in:
parent
a5ac2dcf75
commit
b1ea38bea9
|
@ -250,6 +250,7 @@ class Config:
|
|||
|
||||
self.default_config_path = self.get_default_config_path()
|
||||
if file != None: # configuration file path has been passed
|
||||
file = os.path.expanduser(file)
|
||||
if not os.path.exists(file):
|
||||
print "Configuration file %s not found. Using defaults." % (file)
|
||||
sys.stderr.write("Configuration file %s not found. Using defaults." % (file))
|
||||
|
|
|
@ -28,6 +28,7 @@ import time
|
|||
import fpdb_import
|
||||
from optparse import OptionParser
|
||||
import Configuration
|
||||
import string
|
||||
|
||||
class GuiAutoImport (threading.Thread):
|
||||
def __init__(self, settings, config):
|
||||
|
@ -165,7 +166,11 @@ class GuiAutoImport (threading.Thread):
|
|||
command = os.path.join(sys.path[0], 'HUD_main.py')
|
||||
#command = self.config.execution_path('HUD_main.py') # Hi Ray. Sorry about this, kludging.
|
||||
bs = 1
|
||||
self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
||||
print "GUI:options =", self.settings['cl_options']
|
||||
options = string.split(self.settings['cl_options'])
|
||||
cl = [command, ] + options
|
||||
print "cl =", cl
|
||||
self.pipe_to_hud = subprocess.Popen(cl, bufsize = bs, stdin = subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
# self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
||||
# universal_newlines=True)
|
||||
|
|
|
@ -29,12 +29,20 @@ Main for FreePokerTools HUD.
|
|||
|
||||
# Standard Library modules
|
||||
import sys
|
||||
|
||||
# redirect the stderr
|
||||
errorfile = open('HUD-error.txt', 'w', 0)
|
||||
sys.stderr = errorfile
|
||||
|
||||
import os
|
||||
import Options
|
||||
|
||||
(options, sys.argv) = Options.fpdb_options()
|
||||
|
||||
print "HUD: dbname =", options.dbname
|
||||
print "HUD: config =", options.config
|
||||
print "HUD: logging =", options.errorsToConsole
|
||||
|
||||
if not options.errorsToConsole:
|
||||
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
||||
errorFile = open('fpdb-error-log.txt', 'w', 0)
|
||||
sys.stderr = errorFile
|
||||
|
||||
import thread
|
||||
import time
|
||||
import string
|
||||
|
@ -59,7 +67,7 @@ class HUD_main(object):
|
|||
|
||||
def __init__(self, db_name = 'fpdb'):
|
||||
self.db_name = db_name
|
||||
self.config = Configuration.Config()
|
||||
self.config = Configuration.Config(file=options.config, dbname=options.dbname)
|
||||
self.hud_dict = {}
|
||||
|
||||
# a thread to read stdin
|
||||
|
@ -198,17 +206,12 @@ class HUD_main(object):
|
|||
self.db_connection.connection.rollback()
|
||||
|
||||
if __name__== "__main__":
|
||||
sys.stderr.write("HUD_main starting\n")
|
||||
|
||||
# database name can be passed on command line
|
||||
try:
|
||||
db_name = sys.argv[1]
|
||||
except:
|
||||
db_name = 'fpdb'
|
||||
sys.stderr.write("Using db name = %s\n" % (db_name))
|
||||
sys.stderr.write("HUD_main starting\n")
|
||||
sys.stderr.write("Using db name = %s\n" % (options.dbname))
|
||||
|
||||
# start the HUD_main object
|
||||
hm = HUD_main(db_name = db_name)
|
||||
hm = HUD_main(db_name = options.dbname)
|
||||
|
||||
# start the event loop
|
||||
gtk.main()
|
||||
|
|
|
@ -43,7 +43,7 @@ import Configuration
|
|||
import Stats
|
||||
import Mucked
|
||||
import Database
|
||||
import HUD_main
|
||||
#import HUD_main
|
||||
|
||||
def importName(module_name, name):
|
||||
"""Import a named object 'name' from module 'module_name'."""
|
||||
|
|
45
pyfpdb/Options.py
Normal file
45
pyfpdb/Options.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/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.")
|
||||
(options, sys.argv) = parser.parse_args()
|
||||
return (options, sys.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()
|
|
@ -17,15 +17,11 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
import Options
|
||||
import string
|
||||
|
||||
|
||||
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")
|
||||
(options, sys.argv) = parser.parse_args()
|
||||
cl_options = string.join(sys.argv[1:])
|
||||
(options, sys.argv) = Options.fpdb_options()
|
||||
|
||||
if not options.errorsToConsole:
|
||||
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
||||
|
@ -356,6 +352,7 @@ class fpdb:
|
|||
else:
|
||||
self.settings['os']="windows"
|
||||
|
||||
self.settings.update({'cl_options': cl_options})
|
||||
self.settings.update(self.config.get_db_parameters())
|
||||
self.settings.update(self.config.get_tv_parameters())
|
||||
self.settings.update(self.config.get_import_parameters())
|
||||
|
@ -486,7 +483,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
|||
def __init__(self):
|
||||
self.threads=[]
|
||||
self.db=None
|
||||
self.config = Configuration.Config(dbname=options.dbname)
|
||||
self.config = Configuration.Config(file=options.config, dbname=options.dbname)
|
||||
self.load_profile()
|
||||
|
||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
|
|
Loading…
Reference in New Issue
Block a user