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):
|
def get_layout_node(self, site_node, layout):
|
||||||
for layout_node in site_node.getElementsByTagName("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 ):
|
if int( layout_node.getAttribute("max") ) == int( layout ):
|
||||||
return layout_node
|
return layout_node
|
||||||
|
|
||||||
|
@ -268,8 +270,10 @@ class Config:
|
||||||
|
|
||||||
def edit_layout(self, site_name, max, width = None, height = None,
|
def edit_layout(self, site_name, max, width = None, height = None,
|
||||||
fav_seat = None, locations = None):
|
fav_seat = None, locations = None):
|
||||||
|
print "max = ", max
|
||||||
site_node = self.get_site_node(site_name)
|
site_node = self.get_site_node(site_name)
|
||||||
layout_node = self.get_layout_node(site_node, max)
|
layout_node = self.get_layout_node(site_node, max)
|
||||||
|
if layout_node == None: return
|
||||||
for i in range(1, max + 1):
|
for i in range(1, max + 1):
|
||||||
location_node = self.get_location_node(layout_node, i)
|
location_node = self.get_location_node(layout_node, i)
|
||||||
location_node.setAttribute("x", str( locations[i-1][0] ))
|
location_node.setAttribute("x", str( locations[i-1][0] ))
|
||||||
|
|
|
@ -25,6 +25,7 @@ Create and manage the database objects.
|
||||||
|
|
||||||
# Standard Library modules
|
# Standard Library modules
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
# pyGTK modules
|
# pyGTK modules
|
||||||
|
|
||||||
|
@ -32,30 +33,44 @@ import sys
|
||||||
import Configuration
|
import Configuration
|
||||||
import SQL
|
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:
|
class Database:
|
||||||
def __init__(self, c, db_name, game):
|
def __init__(self, c, db_name, game):
|
||||||
if c.supported_databases[db_name].db_server == 'postgresql':
|
if c.supported_databases[db_name].db_server == 'postgresql':
|
||||||
|
# psycopg2 database module for posgres via DB-API
|
||||||
|
import psycopg2
|
||||||
|
|
||||||
|
try:
|
||||||
self.connection = psycopg2.connect(host = c.supported_databases[db_name].db_ip,
|
self.connection = psycopg2.connect(host = c.supported_databases[db_name].db_ip,
|
||||||
user = c.supported_databases[db_name].db_user,
|
user = c.supported_databases[db_name].db_user,
|
||||||
password = c.supported_databases[db_name].db_pass,
|
password = c.supported_databases[db_name].db_pass,
|
||||||
database = c.supported_databases[db_name].db_name)
|
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':
|
elif c.supported_databases[db_name].db_server == 'mysql':
|
||||||
|
# mysql bindings
|
||||||
|
import MySQLdb
|
||||||
|
try:
|
||||||
self.connection = MySQLdb.connect(host = c.supported_databases[db_name].db_ip,
|
self.connection = MySQLdb.connect(host = c.supported_databases[db_name].db_ip,
|
||||||
user = c.supported_databases[db_name].db_user,
|
user = c.supported_databases[db_name].db_user,
|
||||||
passwd = c.supported_databases[db_name].db_pass,
|
passwd = c.supported_databases[db_name].db_pass,
|
||||||
db = c.supported_databases[db_name].db_name)
|
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:
|
else:
|
||||||
print "Database not recognized."
|
print "Database = %s not recognized." % (c.supported_databases[db_name].db_server)
|
||||||
return(0)
|
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.type = c.supported_databases[db_name].db_type
|
||||||
self.sql = SQL.Sql(game = game, type = self.type)
|
self.sql = SQL.Sql(game = game, type = self.type)
|
||||||
|
@ -155,8 +170,8 @@ class Database:
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
c = Configuration.Config()
|
c = Configuration.Config()
|
||||||
|
|
||||||
# db_connection = Database(c, 'fpdb', 'holdem') # 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, 'fpdb-p', 'test') # mysql fpdb holdem
|
||||||
# db_connection = Database(c, 'PTrackSv2', 'razz') # mysql razz
|
# db_connection = Database(c, 'PTrackSv2', 'razz') # mysql razz
|
||||||
# db_connection = Database(c, 'ptracks', 'razz') # postgres
|
# db_connection = Database(c, 'ptracks', 'razz') # postgres
|
||||||
print "database connection object = ", db_connection.connection
|
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()
|
loc = self.stat_windows[sw].window.get_position()
|
||||||
new_loc = (loc[0] - self.table.x, loc[1] - self.table.y)
|
new_loc = (loc[0] - self.table.x, loc[1] - self.table.y)
|
||||||
new_layout.append(new_loc)
|
new_layout.append(new_loc)
|
||||||
print new_layout
|
# print new_layout
|
||||||
self.config.edit_layout(self.table.site, self.table.max, locations = new_layout)
|
self.config.edit_layout(self.table.site, self.max, locations = new_layout)
|
||||||
self.config.save()
|
self.config.save()
|
||||||
|
|
||||||
def create(self, hand, config):
|
def create(self, hand, config):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user