Merge branch 'master' of git://git.assembla.com/fpdb-eric

This commit is contained in:
Ray 2009-03-23 23:49:04 -04:00
commit 2c492ed0f6
4 changed files with 18 additions and 20 deletions

View File

@ -197,8 +197,8 @@ class GuiBulkImport():
self.load_button.show() self.load_button.show()
# see how many hands are in the db and adjust accordingly # see how many hands are in the db and adjust accordingly
tcursor = db.db.cursor() tcursor = self.importer.fdb.db.cursor()
tcursor.execute("Select count(1) from Hands;") tcursor.execute("Select count(1) from Hands")
row = tcursor.fetchone() row = tcursor.fetchone()
tcursor.close() tcursor.close()
self.n_hands_in_db = row[0] self.n_hands_in_db = row[0]
@ -210,11 +210,9 @@ class GuiBulkImport():
def main(argv=None): def main(argv=None):
"""main can also be called in the python interpreter, by supplying the command line as the argument. """main can also be called in the python interpreter, by supplying the command line as the argument.
>>>import GuiBulkImport >>>import GuiBulkImport
>>>GuiBulkImport.main("-f ~/data/hands")""" >>>GuiBulkImport.main(['-f'.'~/data/hands'])"""
if argv is None: if argv is None:
argv = sys.argv[1:] argv = sys.argv[1:]
else:
argv = argv.split(" ")
def destroy(*args): # call back for terminating the main eventloop def destroy(*args): # call back for terminating the main eventloop
gtk.main_quit() gtk.main_quit()
@ -233,7 +231,7 @@ def main(argv=None):
(options, sys.argv) = parser.parse_args(args = argv) (options, sys.argv) = parser.parse_args(args = argv)
config = Configuration.Config() config = Configuration.Config()
db = fpdb_db.fpdb_db() db = None
settings = {} settings = {}
settings['minPrint'] = options.minPrint settings['minPrint'] = options.minPrint

View File

@ -349,8 +349,8 @@ class Flop_Mucked(Aux_Window):
self.m_windows[i].add(self.eb[i]) self.m_windows[i].add(self.eb[i])
self.seen_cards[i] = gtk.image_new_from_pixbuf(self.card_images[('B', 'H')]) self.seen_cards[i] = gtk.image_new_from_pixbuf(self.card_images[('B', 'H')])
self.eb[i].add(self.seen_cards[i]) self.eb[i].add(self.seen_cards[i])
self.m_windows[i].move(int(x) + self.hud.table.x, int(y) + self.hud.table.y)
self.positions[i] = (int(x) + self.hud.table.x, int(y) + self.hud.table.y) self.positions[i] = (int(x) + self.hud.table.x, int(y) + self.hud.table.y)
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
self.m_windows[i].set_opacity(float(self.params['opacity'])) self.m_windows[i].set_opacity(float(self.params['opacity']))
self.m_windows[i].show_all() self.m_windows[i].show_all()
self.m_windows[i].hide() self.m_windows[i].hide()

View File

@ -178,7 +178,6 @@ class Importer:
tmpcursor = self.fdb.db.cursor() tmpcursor = self.fdb.db.cursor()
tmpcursor.execute("Select count(1) from Hands;") tmpcursor.execute("Select count(1) from Hands;")
self.settings['handsInDB'] = tmpcursor.fetchone()[0] self.settings['handsInDB'] = tmpcursor.fetchone()[0]
tmpcursor.close()
except: except:
pass # if this fails we're probably doomed anyway pass # if this fails we're probably doomed anyway
if self.settings['handsInDB'] < 5000: return "drop" if self.settings['handsInDB'] < 5000: return "drop"

View File

@ -52,7 +52,7 @@ indexes = [
, [ # indexes for postgres (list index 3) , [ # indexes for postgres (list index 3)
{'tab':'Boardcards', 'col':'handId', 'drop':0} {'tab':'Boardcards', 'col':'handId', 'drop':0}
, {'tab':'Gametypes', 'col':'siteId', 'drop':0} , {'tab':'Gametypes', 'col':'siteId', 'drop':0}
, {'tab':'Hands', 'col':'gametypeId', 'drop':1} , {'tab':'Hands', 'col':'gametypeId', 'drop':0} # mct 22/3/09
, {'tab':'Hands', 'col':'siteHandNo', 'drop':0} , {'tab':'Hands', 'col':'siteHandNo', 'drop':0}
, {'tab':'HandsActions', 'col':'handplayerId', 'drop':0} , {'tab':'HandsActions', 'col':'handplayerId', 'drop':0}
, {'tab':'HandsPlayers', 'col':'handId', 'drop':1} , {'tab':'HandsPlayers', 'col':'handId', 'drop':1}
@ -161,12 +161,13 @@ def prepareBulkImport(fdb):
pass pass
elif fdb.backend == PGSQL: elif fdb.backend == PGSQL:
# DON'T FORGET TO RECREATE THEM!! # DON'T FORGET TO RECREATE THEM!!
print "dropping pg fk", fk['fktab'], fk['fkcol'] #print "dropping pg fk", fk['fktab'], fk['fkcol']
try: try:
fdb.cursor.execute("alter table " + fk['fktab'] + " drop constraint " #print "alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol'])
+ fk['fktab'] + '_' + fk['fkcol'] + '_fkey') fdb.cursor.execute("alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol']))
print "dropped pg fk pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol'])
except: except:
pass print "! failed drop pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol'])
else: else:
print "Only MySQL and Postgres supported so far" print "Only MySQL and Postgres supported so far"
return -1 return -1
@ -181,15 +182,15 @@ def prepareBulkImport(fdb):
pass pass
elif fdb.backend == PGSQL: elif fdb.backend == PGSQL:
# DON'T FORGET TO RECREATE THEM!! # DON'T FORGET TO RECREATE THEM!!
print "Index dropping disabled for postgresql." #print "Index dropping disabled for postgresql."
print "dropping pg index ", idx['tab'], idx['col'] #print "dropping pg index ", idx['tab'], idx['col']
# mod to use tab_col for index name? # mod to use tab_col for index name?
try: try:
print "drop index %s_%s_idx" % (idx['tab'],idx['col'])
fdb.cursor.execute( "drop index %s_%s_idx" % (idx['tab'],idx['col']) ) fdb.cursor.execute( "drop index %s_%s_idx" % (idx['tab'],idx['col']) )
print "dropped pg index ", idx['tab'], idx['col'] print "drop index %s_%s_idx" % (idx['tab'],idx['col'])
#print "dropped pg index ", idx['tab'], idx['col']
except: except:
pass print "! failed drop index %s_%s_idx" % (idx['tab'],idx['col'])
else: else:
print "Only MySQL and Postgres supported so far" print "Only MySQL and Postgres supported so far"
return -1 return -1
@ -612,7 +613,7 @@ def filterAnteBlindFold(site,hand):
if foldeeName in line: if foldeeName in line:
hand[i] = None hand[i] = None
hand = [line for line in hand if line] return [line for line in hand if line]
#end def filterAnteFold #end def filterAnteFold
def stripEOLspaces(str): def stripEOLspaces(str):