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()
|
self.default_config_path = self.get_default_config_path()
|
||||||
if file != None: # configuration file path has been passed
|
if file != None: # configuration file path has been passed
|
||||||
|
file = os.path.expanduser(file)
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
print "Configuration file %s not found. Using defaults." % (file)
|
print "Configuration file %s not found. Using defaults." % (file)
|
||||||
sys.stderr.write("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
|
import fpdb_import
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import Configuration
|
import Configuration
|
||||||
|
import string
|
||||||
|
|
||||||
class GuiAutoImport (threading.Thread):
|
class GuiAutoImport (threading.Thread):
|
||||||
def __init__(self, settings, config):
|
def __init__(self, settings, config):
|
||||||
|
@ -165,7 +166,11 @@ class GuiAutoImport (threading.Thread):
|
||||||
command = os.path.join(sys.path[0], 'HUD_main.py')
|
command = os.path.join(sys.path[0], 'HUD_main.py')
|
||||||
#command = self.config.execution_path('HUD_main.py') # Hi Ray. Sorry about this, kludging.
|
#command = self.config.execution_path('HUD_main.py') # Hi Ray. Sorry about this, kludging.
|
||||||
bs = 1
|
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)
|
universal_newlines=True)
|
||||||
# self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
# self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
||||||
# universal_newlines=True)
|
# universal_newlines=True)
|
||||||
|
|
|
@ -29,12 +29,20 @@ Main for FreePokerTools HUD.
|
||||||
|
|
||||||
# Standard Library modules
|
# Standard Library modules
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# redirect the stderr
|
|
||||||
errorfile = open('HUD-error.txt', 'w', 0)
|
|
||||||
sys.stderr = errorfile
|
|
||||||
|
|
||||||
import os
|
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 thread
|
||||||
import time
|
import time
|
||||||
import string
|
import string
|
||||||
|
@ -59,7 +67,7 @@ class HUD_main(object):
|
||||||
|
|
||||||
def __init__(self, db_name = 'fpdb'):
|
def __init__(self, db_name = 'fpdb'):
|
||||||
self.db_name = db_name
|
self.db_name = db_name
|
||||||
self.config = Configuration.Config()
|
self.config = Configuration.Config(file=options.config, dbname=options.dbname)
|
||||||
self.hud_dict = {}
|
self.hud_dict = {}
|
||||||
|
|
||||||
# a thread to read stdin
|
# a thread to read stdin
|
||||||
|
@ -198,17 +206,12 @@ class HUD_main(object):
|
||||||
self.db_connection.connection.rollback()
|
self.db_connection.connection.rollback()
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
sys.stderr.write("HUD_main starting\n")
|
|
||||||
|
|
||||||
# database name can be passed on command line
|
sys.stderr.write("HUD_main starting\n")
|
||||||
try:
|
sys.stderr.write("Using db name = %s\n" % (options.dbname))
|
||||||
db_name = sys.argv[1]
|
|
||||||
except:
|
|
||||||
db_name = 'fpdb'
|
|
||||||
sys.stderr.write("Using db name = %s\n" % (db_name))
|
|
||||||
|
|
||||||
# start the HUD_main object
|
# start the HUD_main object
|
||||||
hm = HUD_main(db_name = db_name)
|
hm = HUD_main(db_name = options.dbname)
|
||||||
|
|
||||||
# start the event loop
|
# start the event loop
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
|
@ -43,7 +43,7 @@ import Configuration
|
||||||
import Stats
|
import Stats
|
||||||
import Mucked
|
import Mucked
|
||||||
import Database
|
import Database
|
||||||
import HUD_main
|
#import HUD_main
|
||||||
|
|
||||||
def importName(module_name, name):
|
def importName(module_name, name):
|
||||||
"""Import a named object 'name' from module 'module_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 os
|
||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser
|
import Options
|
||||||
|
import string
|
||||||
|
|
||||||
|
cl_options = string.join(sys.argv[1:])
|
||||||
parser = OptionParser()
|
(options, sys.argv) = Options.fpdb_options()
|
||||||
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()
|
|
||||||
|
|
||||||
if not 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_."
|
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:
|
else:
|
||||||
self.settings['os']="windows"
|
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_db_parameters())
|
||||||
self.settings.update(self.config.get_tv_parameters())
|
self.settings.update(self.config.get_tv_parameters())
|
||||||
self.settings.update(self.config.get_import_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):
|
def __init__(self):
|
||||||
self.threads=[]
|
self.threads=[]
|
||||||
self.db=None
|
self.db=None
|
||||||
self.config = Configuration.Config(dbname=options.dbname)
|
self.config = Configuration.Config(file=options.config, dbname=options.dbname)
|
||||||
self.load_profile()
|
self.load_profile()
|
||||||
|
|
||||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user