Merge branch 'master' of git://git.assembla.com/free_poker_tools

This commit is contained in:
Worros 2009-01-27 19:35:35 +09:00
commit 1179067033
6 changed files with 74 additions and 9 deletions

View File

@ -20,7 +20,7 @@ import pygtk
pygtk.require('2.0')
import gtk
import os
from time import time
from time import *
#import pokereval
try:
@ -366,3 +366,31 @@ class GuiGraphViewer (threading.Thread):
self.leftPanelBox.show()
self.graphBox.show()
#################################
self.db.cursor.execute("""select UNIX_TIMESTAMP(handStart) as time, id from Hands ORDER BY time""")
THRESHOLD = 1800
hands = self.db.cursor.fetchall()
times = map(lambda x:long(x[0]), hands)
handids = map(lambda x:int(x[1]), hands)
print "DEBUG: len(times) %s" %(len(times))
diffs = diff(times)
print "DEBUG: len(diffs) %s" %(len(diffs))
index = nonzero(diff(times) > THRESHOLD)
print "DEBUG: len(index[0]) %s" %(len(index[0]))
print "DEBUG: index %s" %(index)
print "DEBUG: index[0][0] %s" %(index[0][0])
total = 0
last_idx = 0
for i in range(len(index[0])):
print "Hands in session %4s: %4s Start: %s End: %s Total: %s" %(i, index[0][i] - last_idx, strftime("%d/%m/%Y %H:%M", localtime(times[last_idx])), strftime("%d/%m/%Y %H:%M", localtime(times[index[0][i]])), times[index[0][i]] - times[last_idx])
total = total + (index[0][i] - last_idx)
last_idx = index[0][i] + 1
print "Total: ", total
#################################

View File

@ -67,7 +67,7 @@ class GuiPlayerStats (threading.Thread):
for t in titles:
l = gtk.Label(titles[col])
l.show()
self.stats_table.attach(l, col, col+1, row, row+1)
self.stats_table.attach(l, col, col+1, row, row+1, yoptions=gtk.SHRINK)
col +=1
for row in range(rows-1):
@ -87,7 +87,7 @@ class GuiPlayerStats (threading.Thread):
else:
l.set_alignment(xalign=1.0, yalign=0.5)
eb.add(l)
self.stats_table.attach(eb, col, col+1, row+1, row+2)
self.stats_table.attach(eb, col, col+1, row+1, row+2, yoptions=gtk.SHRINK)
l.show()
eb.show()
self.fdb.db.commit()

View File

@ -65,7 +65,7 @@ def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_conn
gtk.gdk.threads_enter()
try:
newlabel = gtk.Label(table_name)
newlabel = gtk.Label(table.site + " - " + table_name)
eb.add(newlabel)
newlabel.show()
@ -98,9 +98,12 @@ def update_HUD(new_hand_id, table_name, config, stat_dict):
def HUD_removed(tablename):
global hud_dict, eb
tablename = Tables.clean_title(tablename)
# TODO: There's a potential problem here somewhere, that this hacks around .. the table_name as being passed to HUD_create is cleaned,
# but the table.name as being passed here is not cleaned. I don't know why. -eric
if tablename in hud_dict and hud_dict[tablename].deleted:
eb.remove(hud_dict[tablename].tablehudlabel)
del(hud_dict[tablename])
del hud_dict[tablename]
return False
return True

View File

@ -76,7 +76,7 @@ class Hud:
self.main_window = gtk.Window()
self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC)
self.main_window.set_title(table.name + " FPDBHUD")
self.main_window.connect("destroy", self.kill_hud)
self.main_window.destroyhandler = self.main_window.connect("destroy", self.kill_hud)
self.main_window.set_decorated(False)
self.main_window.set_opacity(self.colors["hudopacity"])
@ -101,7 +101,7 @@ class Hud:
self.menu = gtk.Menu()
self.item1 = gtk.MenuItem('Kill this HUD')
self.menu.append(self.item1)
self.item1.connect("activate", self.kill_hud)
self.item1.connect("activate", self.kill_hud_menu)
self.item1.show()
self.item2 = gtk.MenuItem('Save Layout')
@ -163,11 +163,22 @@ class Hud:
return False
def kill_hud(self, *args):
if self.deleted:
return # no killing self twice.
for k in self.stat_windows:
self.stat_windows[k].window.destroy()
self.main_window.destroy()
# also kill any aux windows
for m in self.aux_windows:
m.destroy()
self.aux_windows.remove(m)
self.deleted = True
self.main_window.disconnect(self.main_window.destroyhandler) # so we don't potentially infiniteloop in here, right
self.main_window.destroy()
HUD_main.HUD_removed(self.table.name)
def kill_hud_menu(self, *args):
self.main_window.destroy()
def reposition_windows(self, *args):
for w in self.stat_windows:
@ -354,23 +365,29 @@ class Stat_Window:
self.grid = gtk.Table(rows = self.game.rows, columns = self.game.cols, homogeneous = False)
self.window.add(self.grid)
self.window.modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
self.e_box = []
self.frame = []
self.label = []
for r in range(self.game.rows):
self.frame.append([])
self.e_box.append([])
self.label.append([])
for c in range(self.game.cols):
self.frame[r].append( gtk.Frame() )
self.e_box[r].append( gtk.EventBox() )
self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor)
Stats.do_tip(self.e_box[r][c], 'stuff')
self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0)
# self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0)
self.grid.attach(self.frame[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0)
self.frame[r][c].add(self.e_box[r][c])
self.label[r].append( gtk.Label('xxx') )
self.frame[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
self.label[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
self.label[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor)

View File

@ -50,6 +50,9 @@ class Aux_Window:
def update_gui(self):
pass
def destroy(self):
self.container.destroy()
class Stud_mucked(Aux_Window):
def __init__(self, container, hud, config, params):

View File

@ -35,6 +35,7 @@ if os.name == 'nt':
import win32process
import win32api
import win32con
import win32security
# FreePokerTools modules
import Configuration
@ -250,10 +251,23 @@ def discover_nt_tournament(c, tour_number, tab_number):
def get_nt_exe(hwnd):
"""Finds the name of the executable that the given window handle belongs to."""
# Request privileges to enable "debug process", so we can later use PROCESS_VM_READ, retardedly required to GetModuleFileNameEx()
priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess(), priv_flags)
# enable "debug process"
privilege_id = win32security.LookupPrivilegeValue (None, win32security.SE_DEBUG_NAME)
old_privs = win32security.AdjustTokenPrivileges (hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)])
# Open the process, and query it's filename
processid = win32process.GetWindowThreadProcessId(hwnd)
pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1])
exename = win32process.GetModuleFileNameEx(pshandle, 0)
# clean up
win32api.CloseHandle(pshandle)
win32api.CloseHandle(hToken)
return exename
def decode_windows(c, title, hwnd):