fix bug in saving layouts
This commit is contained in:
parent
31d40a6274
commit
3b618723d2
|
@ -247,6 +247,8 @@ class Config:
|
|||
|
||||
def get_layout_node(self, site_node, layout):
|
||||
for layout_node in site_node.getElementsByTagName("layout"):
|
||||
if layout_node.getAttribute("max") == None:
|
||||
return None
|
||||
if int( layout_node.getAttribute("max") ) == int( layout ):
|
||||
return layout_node
|
||||
|
||||
|
@ -268,8 +270,10 @@ class Config:
|
|||
|
||||
def edit_layout(self, site_name, max, width = None, height = None,
|
||||
fav_seat = None, locations = None):
|
||||
print "max = ", max
|
||||
site_node = self.get_site_node(site_name)
|
||||
layout_node = self.get_layout_node(site_node, max)
|
||||
if layout_node == None: return
|
||||
for i in range(1, max + 1):
|
||||
location_node = self.get_location_node(layout_node, i)
|
||||
location_node.setAttribute("x", str( locations[i-1][0] ))
|
||||
|
|
|
@ -25,6 +25,7 @@ Create and manage the database objects.
|
|||
|
||||
# Standard Library modules
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
# pyGTK modules
|
||||
|
||||
|
@ -32,30 +33,44 @@ import sys
|
|||
import Configuration
|
||||
import SQL
|
||||
|
||||
# pgdb database module for posgres via DB-API
|
||||
import psycopg2
|
||||
# pgdb uses pyformat. is that fixed or an option?
|
||||
|
||||
# mysql bindings
|
||||
import MySQLdb
|
||||
|
||||
class Database:
|
||||
def __init__(self, c, db_name, game):
|
||||
if c.supported_databases[db_name].db_server == 'postgresql':
|
||||
self.connection = psycopg2.connect(host = c.supported_databases[db_name].db_ip,
|
||||
# psycopg2 database module for posgres via DB-API
|
||||
import psycopg2
|
||||
|
||||
try:
|
||||
self.connection = psycopg2.connect(host = c.supported_databases[db_name].db_ip,
|
||||
user = c.supported_databases[db_name].db_user,
|
||||
password = c.supported_databases[db_name].db_pass,
|
||||
database = c.supported_databases[db_name].db_name)
|
||||
except:
|
||||
print "Error opening database connection %s. See error log file." % (file)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
print "press enter to continue"
|
||||
sys.stdin.readline()
|
||||
sys.exit()
|
||||
|
||||
elif c.supported_databases[db_name].db_server == 'mysql':
|
||||
self.connection = MySQLdb.connect(host = c.supported_databases[db_name].db_ip,
|
||||
# mysql bindings
|
||||
import MySQLdb
|
||||
try:
|
||||
self.connection = MySQLdb.connect(host = c.supported_databases[db_name].db_ip,
|
||||
user = c.supported_databases[db_name].db_user,
|
||||
passwd = c.supported_databases[db_name].db_pass,
|
||||
db = c.supported_databases[db_name].db_name)
|
||||
except:
|
||||
print "Error opening database connection %s. See error log file." % (file)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
print "press enter to continue"
|
||||
sys.stdin.readline()
|
||||
sys.exit()
|
||||
|
||||
else:
|
||||
print "Database not recognized."
|
||||
return(0)
|
||||
print "Database = %s not recognized." % (c.supported_databases[db_name].db_server)
|
||||
sys.stderr.write("Database not recognized, exiting.\n")
|
||||
print "press enter to continue"
|
||||
sys.exit()
|
||||
|
||||
self.type = c.supported_databases[db_name].db_type
|
||||
self.sql = SQL.Sql(game = game, type = self.type)
|
||||
|
@ -155,8 +170,8 @@ class Database:
|
|||
if __name__=="__main__":
|
||||
c = Configuration.Config()
|
||||
|
||||
# db_connection = Database(c, 'fpdb', 'holdem') # mysql fpdb holdem
|
||||
db_connection = Database(c, 'fpdb-p', 'test') # mysql fpdb holdem
|
||||
db_connection = Database(c, 'fpdb', 'holdem') # mysql fpdb holdem
|
||||
# db_connection = Database(c, 'fpdb-p', 'test') # mysql fpdb holdem
|
||||
# db_connection = Database(c, 'PTrackSv2', 'razz') # mysql razz
|
||||
# db_connection = Database(c, 'ptracks', 'razz') # postgres
|
||||
print "database connection object = ", db_connection.connection
|
||||
|
|
4
pyfpdb/Hud.py
Executable file → Normal file
4
pyfpdb/Hud.py
Executable file → Normal file
|
@ -105,8 +105,8 @@ class Hud:
|
|||
loc = self.stat_windows[sw].window.get_position()
|
||||
new_loc = (loc[0] - self.table.x, loc[1] - self.table.y)
|
||||
new_layout.append(new_loc)
|
||||
print new_layout
|
||||
self.config.edit_layout(self.table.site, self.table.max, locations = new_layout)
|
||||
# print new_layout
|
||||
self.config.edit_layout(self.table.site, self.max, locations = new_layout)
|
||||
self.config.save()
|
||||
|
||||
def create(self, hand, config):
|
||||
|
|
Loading…
Reference in New Issue
Block a user