def fillPlayerFrame(self, frame, display): vbox = QVBoxLayout() frame.setLayout(vbox) for site in self.conf.get_supported_sites(): player = self.conf.supported_sites[site].screen_name _pname = Charset.to_gui(player) vbox.addWidget(QLabel(site + " id:")) self.leHeroes[site] = QLineEdit(_pname) vbox.addWidget(self.leHeroes[site]) names = self.db.get_player_names(self.conf, self.siteid[site]) completer = QCompleter([Charset.to_gui(n[0]) for n in names]) self.leHeroes[site].setCompleter(completer) if "GroupsAll" in display and display["GroupsAll"]: hbox = QHBoxLayout() vbox.addLayout(hbox) self.cbGroups['allplayers'] = QCheckBox( self.filterText['groupsall']) hbox.addWidget(self.cbGroups['allplayers']) lbl = QLabel(_('Min # Hands:')) hbox.addWidget(lbl) self.phands = QSpinBox() self.phands.setMaximum(1e5) hbox.addWidget(self.phands)
def fillStatsFrame(self, vbox): sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() type = self.filters.getType() seats = self.filters.getSeats() groups = self.filters.getGroups() dates = self.filters.getDates() games = self.filters.getGames() sitenos = [] playerids = [] # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") sitenos = [2] if not playerids: print _("No player ids found") return if not limits: print _("No limits found") return self.createStatsTable(vbox, playerids, sitenos, limits, type, seats, groups, dates, games)
def fillStatsFrame(self, vbox): tourneyTypes = self.filters.getTourneyTypes() #tourneys = self.tourneys.getTourneys() sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() seats = self.filters.getSeats() dates = self.filters.getDates() sitenos = [] playerids = [] tourneysName = [] # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") sitenos = [2] if not playerids: print _("No player ids found") return self.createStatsTable(vbox, tourneyTypes, playerids, sitenos, seats)
def fillStatsFrame(self, vbox): sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() seats = self.filters.getSeats() sitenos = [] playerids = [] # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _q = self.sql.query['getPlayerId'] _name = Charset.to_utf8(heroes[site]) #print 'DEBUG(_name) :: %s' % _name self.cursor.execute(_q, (_name,)) # arg = tuple result = self.db.cursor.fetchall() if len(result) == 1: playerids.append(result[0][0]) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") sitenos = [2] if not playerids: print _("No player ids found") return if not limits: print _("No limits found") return self.createStatsPane(vbox, playerids, sitenos, limits, seats)
def createPlayerLine(self, hbox, site, player): log.debug('add:"%s"' % player) label = gtk.Label(site + " id:") hbox.pack_start(label, False, False, 3) pname = gtk.Entry() pname.set_text(player) pname.set_width_chars(20) hbox.pack_start(pname, False, True, 0) pname.connect("changed", self.__set_hero_name, site) # Added EntryCompletion but maybe comboBoxEntry is more flexible? (e.g. multiple choices) completion = gtk.EntryCompletion() pname.set_completion(completion) liststore = gtk.ListStore(gobject.TYPE_STRING) completion.set_model(liststore) completion.set_text_column(0) names = self.db.get_player_names( self.conf, self.siteid[site] ) # (config=self.conf, site_id=None, like_player_name="%") for n in names: # list of single-element "tuples" _n = Charset.to_gui(n[0]) _nt = (_n,) liststore.append(_nt) self.__set_hero_name(pname, site)
def fillStatsFrame(self, vbox): sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() seats = self.filters.getSeats() sitenos = [] playerids = [] # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _q = self.sql.query['getPlayerId'] _name = Charset.to_utf8(heroes[site]) #print 'DEBUG(_name) :: %s' % _name self.cursor.execute(_q, (_name, )) # arg = tuple result = self.db.cursor.fetchall() if len(result) == 1: playerids.append(result[0][0]) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") sitenos = [2] if not playerids: print _("No player ids found") return if not limits: print _("No limits found") return self.createStatsPane(vbox, playerids, sitenos, limits, seats)
def createPlayerLine(self, hbox, site, player): log.debug('add:"%s"' % player) label = gtk.Label(site + " id:") hbox.pack_start(label, False, False, 3) pname = gtk.Entry() pname.set_text(player) pname.set_width_chars(20) hbox.pack_start(pname, False, True, 0) pname.connect("changed", self.__set_hero_name, site) # Added EntryCompletion but maybe comboBoxEntry is more flexible? (e.g. multiple choices) completion = gtk.EntryCompletion() pname.set_completion(completion) liststore = gtk.ListStore(gobject.TYPE_STRING) completion.set_model(liststore) completion.set_text_column(0) names = self.db.get_player_names( self.conf, self.siteid[site] ) # (config=self.conf, site_id=None, like_player_name="%") for n in names: # list of single-element "tuples" _n = Charset.to_gui(n[0]) _nt = (_n, ) liststore.append(_nt) self.__set_hero_name(pname, site)
def replace_placeholders_with_filter_values(self, query): """ Returnes given query with replaced placeholders by the filter values from self. List of Placeholders that are replaced and some infos how the statement has to look like: (whole clause means it starts with AND and contains the whole clause) Placeholders table & alias or field SQL usage coresponding filter Name <player_test> Players.Id in <player_test> Heroes <game_test> GameType gt whole clause Game <limit_test> GameType gt whole clause Limits, LimitSep, LimitType <position_test> HandsPlayers hp whole clause Positions """ if '<game_test>' in query: games = self.getGames() if len(games) > 0: gametest = str(tuple(games)) gametest = gametest.replace("L", "") gametest = gametest.replace(",)", ")") gametest = gametest.replace("u'", "'") gametest = "and gt.category in %s" % gametest else: gametest = "and gt.category IS NULL" query = query.replace('<game_test>', gametest) if '<limit_test>' in query: #copyed from GuiGraphView limits = self.getLimits() limittest = self.get_limits_where_clause(limits) query = query.replace('<limit_test>', limittest) if '<player_test>' in query: #copyed from GuiGraphView sites = self.getSites() heroes = self.getHeroes() siteids = self.getSiteIds() sitenos = [] playerids = [] for site in sites: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(str(result)) query = query.replace('<player_test>', '(' + ','.join(playerids) + ')') if '<position_test>' in query: positions = self.getPositions() positiontest = "AND hp.position in ('" + "','".join( positions ) + "')" #values must be set in '' because they can be strings as well as numbers query = query.replace('<position_test>', positiontest) return query
def fillStatsFrame(self, vbox): sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() games = self.filters.getGames() currencies = self.filters.getCurrencies() limits = self.filters.getLimits() seats = self.filters.getSeats() sitenos = [] playerids = [] for i in ('show', 'none'): if i in limits: limits.remove(i) # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(result) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") sitenos = [2] if not games: print _("No games found") return if not currencies: print _("No currencies found") return if not playerids: print _("No player ids found") return if not limits: print _("No limits found") return self.createStatsPane(vbox, playerids, sitenos, games, currencies, limits, seats)
def fillPlayerFrame(self, vbox, display): top_hbox = gtk.HBox(False, 0) vbox.pack_start(top_hbox, False, False, 0) lbl_title = gtk.Label(self.filterText['playerstitle']) lbl_title.set_alignment(xalign=0.0, yalign=0.5) top_hbox.pack_start(lbl_title, expand=True, padding=3) showb = gtk.Button(label=_("Refresh"), stock=None, use_underline=True) showb.set_alignment(xalign=1.0, yalign=0.5) showb.connect('clicked', self.__refresh, 'players') vbox1 = gtk.VBox(False, 0) vbox.pack_start(vbox1, False, False, 0) self.boxes['players'] = vbox1 for site in self.conf.get_supported_sites(): hBox = gtk.HBox(False, 0) vbox1.pack_start(hBox, False, True, 0) player = self.conf.supported_sites[site].screen_name _pname = Charset.to_gui(player) self.createPlayerLine(hBox, site, _pname) if "GroupsAll" in display and display["GroupsAll"] == True: hbox = gtk.HBox(False, 0) vbox1.pack_start(hbox, False, False, 0) cb = gtk.CheckButton(self.filterText['groupsall']) cb.connect('clicked', self.__set_group_select, 'allplayers') hbox.pack_start(cb, False, False, 0) self.sbGroups['allplayers'] = cb self.groups['allplayers'] = False lbl = gtk.Label(_('Min # Hands:')) lbl.set_alignment(xalign=1.0, yalign=0.5) hbox.pack_start(lbl, expand=True, padding=3) phands = gtk.Entry() phands.set_text('0') phands.set_width_chars(8) hbox.pack_start(phands, False, False, 0) phands.connect("changed", self.__set_num_hands, site) top_hbox.pack_start(showb, expand=False, padding=1)
def fillPlayerFrame(self, vbox, display): top_hbox = gtk.HBox(False, 0) vbox.pack_start(top_hbox, False, False, 0) lbl_title = gtk.Label(self.filterText['playerstitle']) lbl_title.set_alignment(xalign=0.0, yalign=0.5) top_hbox.pack_start(lbl_title, expand=True, padding=3) showb = gtk.Button(label="refresh", stock=None, use_underline=True) showb.set_alignment(xalign=1.0, yalign=0.5) showb.connect('clicked', self.__refresh, 'players') vbox1 = gtk.VBox(False, 0) vbox.pack_start(vbox1, False, False, 0) self.boxes['players'] = vbox1 for site in self.conf.get_supported_sites(): hBox = gtk.HBox(False, 0) vbox1.pack_start(hBox, False, True, 0) player = self.conf.supported_sites[site].screen_name _pname = Charset.to_gui(player) self.createPlayerLine(hBox, site, _pname) if "GroupsAll" in display and display["GroupsAll"] == True: hbox = gtk.HBox(False, 0) vbox1.pack_start(hbox, False, False, 0) cb = gtk.CheckButton(self.filterText['groupsall']) cb.connect('clicked', self.__set_group_select, 'allplayers') hbox.pack_start(cb, False, False, 0) self.sbGroups['allplayers'] = cb self.groups['allplayers'] = False lbl = gtk.Label(_('Min # Hands:')) lbl.set_alignment(xalign=1.0, yalign=0.5) hbox.pack_start(lbl, expand=True, padding=3) phands = gtk.Entry() phands.set_text('0') phands.set_width_chars(8) hbox.pack_start(phands, False, False, 0) phands.connect("changed", self.__set_num_hands, site) top_hbox.pack_start(showb, expand=False, padding=1)
def set_charset(self, charset): """Set the charset of the payload to a given character set. charset can be a Charset instance, a string naming a character set, or None. If it is a string it will be converted to a Charset instance. If charset is None, the charset parameter will be removed from the Content-Type field. Anything else will generate a TypeError. The message will be assumed to be of type text/* encoded with charset.input_charset. It will be converted to charset.output_charset and encoded properly, if needed, when generating the plain text representation of the message. MIME headers (MIME-Version, Content-Type, Content-Transfer-Encoding) will be added as needed. """ if charset is None: self.del_param('charset') self._charset = None return if isinstance(charset, StringType): charset = Charset.Charset(charset) if not isinstance(charset, Charset.Charset): raise TypeError, charset # BAW: should we accept strings that can serve as arguments to the # Charset constructor? self._charset = charset if 'MIME-Version' not in self: self.add_header('MIME-Version', '1.0') if 'Content-Type' not in self: self.add_header('Content-Type', 'text/plain', charset=charset.get_output_charset()) else: self.set_param('charset', charset.get_output_charset()) if 'Content-Transfer-Encoding' not in self: cte = charset.get_body_encoding() if callable(cte): cte(self) else: self.add_header('Content-Transfer-Encoding', cte)
def main(): #Initialize Everything pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode((640, 480)) table_no = 1 table_title = "Valparaíso / aaaaaaaaaaaaaaaaa" pygame.display.set_caption(Charset.to_utf8(table_title)) pygame.mouse.set_visible(0) # Load background image bgimage, rect = load_image('../gfx/Table.png') background = pygame.Surface(screen.get_size()) background.blit(bgimage, (0, 0)) #Put Text On The Background, Centered if pygame.font: font = pygame.font.Font(None, 24) text = font.render("Yarmouth Texas Hold'em NL -$0.01/$0.02", 1, (10, 10, 10)) textpos = text.get_rect(centerx=background.get_width()/2) background.blit(text, textpos) #Display The Background screen.blit(background, (0, 0)) pygame.display.flip() going = True while going: clock.tick(6000) # Draw screen.blit(background, (0, 0)) # Change table # #table_no += 1 #table_title = "Tournament 2010090009 Table %s - Blinds $600/$1200 Anto $150" % table_no #pygame.display.set_caption(table_title) time.sleep(10)
def generateGraph(self, widget, data): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() (green, dates, transfersAmount, transfersDate, transferType) = self.getData(playerids, sitenos) print _("Graph generated in: %s") % (time() - starttime) #Set axis labels and grid overlay properites self.ax.set_ylabel("$", fontsize=12) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) self.ax.plot(green, color='green', label=_('Bankroll') + _('Profit') + ': $%.2f' % green[-1]) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #TODO: Do something useful like alert user else: self.ax.set_title(_("Bankroll Results")) useDates = True #nothing to draw if (len(green) == 0): return #Get the dates of the action (transfert / cg hand / tourney) #if it has no date, get the most ancient date and assume it's its one if dates[0] is None: i = 1 while i < len(dates) and type(dates[i]) is None: i = i + 1 if i == len(dates): print "Wow wow wow : no dates in your whole database" useDates = False else: dates[0] = dates[i] #now, convert date to dateTime format if useDates: for i in range(0, len(dates)): if dates[i] is None: dates[i] = dates[i - 1] #~else: #~dates[i] = datetime.datetime.strptime(dates[i], "%Y-%m-%d %H:%M:%S") for i in range(0, len(green) - 1): beneficeSinceStart = green[i + 1] - self.totalTransfer( dates[i + 1], transfersAmount, transfersDate) mycolor = self.color(transferType[i + 1], beneficeSinceStart) self.ax.plot([i, i + 1], [green[i], green[i + 1]], color=mycolor) #show date and gain only 5 times on X axis if (i % (len(green) / 5) == 1): #the gain since start at this time if (mycolor == 'cyan'): mycolor = 'green' self.ax.annotate('%.2f' % beneficeSinceStart, xy=(i, 0), color=mycolor, xycoords=('data', 'axes fraction'), xytext=(0, 18), textcoords='offset points', va='top', ha='left') #and show the date too if enabled if useDates: dateMMDD = datetime.datetime.strptime( dates[i], "%Y-%m-%d %H:%M:%S").strftime('%d/%m') self.ax.annotate(dateMMDD, xy=(i, 0), xycoords=('data', 'axes fraction'), xytext=(0, -18), textcoords='offset points', va='top', ha='left') #plot the last one and show the top corner legend i = len(green) - 1 bankroll = float(green[i]) profit = bankroll if len(transfersAmount) > 0: profit -= transfersAmount[len(transfersAmount) - 1] self.ax.plot([i, i + 1], [green[i], green[i]], color=self.color(transferType[i], beneficeSinceStart), label=_('Bankroll') + ': \$%.2f' % bankroll + '\n' + _('Profit') + ': \$%.2f' % profit) legend = self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) legend.draggable(True) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw()
def generateGraph(self, widget, data): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() currencies = self.filters.getCurrencies() # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() (green, datesXAbs) = self.getData(playerids, sitenos, currencies) print _("Graph generated in: %s") %(time() - starttime) currencyLabel = ','.join(['%s' % key for key in currencies.keys()]) #Set axis labels and grid overlay properites self.ax.set_ylabel(currencyLabel, fontsize = 12) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) self.ax.plot(green, color='green', label=_('Tournaments') + ': %d\n' % len(green) + _('Profit') + '(' + currencyLabel + '): %.2f' % green[-1]) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #TODO: Do something useful like alert user else: self.ax.set_title(_("Tournament Results")) useDates = True #nothing to draw if (len(green) == 0): return #Get the dates of tourneys #if first tourney has no date, get the most ancient date and assume it's his one if datesXAbs[0] is None: i = 1 while i < len(datesXAbs) and type(datesXAbs[i]) is None: i = i+1 if i == len(datesXAbs): print "Wow wow wow : no dates in your whole tourneys" useDates = False else: datesXAbs[0] = datesXAbs[i] #now convert date to dateTime format if useDates: for i in range(0, len(datesXAbs)): if datesXAbs[i] is None: datesXAbs[i] = datesXAbs[i-1] else: datesXAbs[i] = datetime.datetime.strptime(datesXAbs[i], "%Y-%m-%d %H:%M:%S") datesXAbs[i] = datesXAbs[i].strftime('%d/%m') mycolor='red' if green[0]>0: mycolor='green' self.ax.plot([0,1], [0,green[0]], color=mycolor, label=_('Tournaments') + ': %d\n' % len(green) + _('Profit') + '(' + currencyLabel + '): %.2f' % green[-1]) for i in range(1, len(green)): final=green[i]-green[i-1] mycolor='red' if (green[i]>0): mycolor='green' self.ax.plot([i,i+1], [green[i-1],green[i]], color=mycolor) if (i % (len(green)/5) == 0): gain="" if (green[i]==0): gain="=" else: if (green[i]>0): gain="+" gain += str(green[i]) self.ax.annotate(gain, xy=(i, 0), color=mycolor, xycoords=('data', 'axes fraction'), xytext=(0, 18), textcoords='offset points', va='top', ha='left') if useDates: self.ax.annotate(datesXAbs[i], xy=(i, 0), xycoords=('data', 'axes fraction'), xytext=(0, -18), textcoords='offset points', va='top', ha='left') #~self.ax.axhline(0, color='black', lw=2) legend = self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) legend.draggable(True) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw()
def generateGraph(self, widget, data): try: self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() games = self.filters.getGames() for i in ('show', 'none'): if i in limits: limits.remove(i) # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print "No sites selected - defaulting to PokerStars" self.db.rollback() return if not playerids: print "No player ids found" self.db.rollback() return if not limits: print "No limits found" self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() (green, blue, red) = self.getRingProfitGraph(playerids, sitenos, limits, games) print "Graph generated in: %s" %(time() - starttime) #Set axis labels and grid overlay properites self.ax.set_xlabel("Hands", fontsize = 12) self.ax.set_ylabel("$", fontsize = 12) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title("No Data for Player(s) Found") green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) self.ax.plot(green, color='green', label='Hands: %d\nProfit: $%.2f' %(len(green), green[-1])) self.ax.plot(blue, color='blue', label='Showdown: $%.2f' %(blue[-1])) self.ax.plot(red, color='red', label='Non-showdown: $%.2f' %(red[-1])) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #TODO: Do something useful like alert user #print "No hands returned by graph query" else: self.ax.set_title("Profit graph for ring games") #text = "Profit: $%.2f\nTotal Hands: %d" %(green[-1], len(green)) #self.ax.annotate(text, # xy=(10, -10), # xycoords='axes points', # horizontalalignment='left', verticalalignment='top', # fontsize=10) #Draw plot self.ax.plot(green, color='green', label='Hands: %d\nProfit: $%.2f' %(len(green), green[-1])) self.ax.plot(blue, color='blue', label='Showdown: $%.2f' %(blue[-1])) self.ax.plot(red, color='red', label='Non-showdown: $%.2f' %(red[-1])) if sys.version[0:3] == '2.5': self.ax.legend(loc='best', shadow=True, prop=FontProperties(size='smaller')) else: self.ax.legend(loc='best', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #self.exportButton.set_sensitive(True) except: err = traceback.extract_tb(sys.exc_info()[2])[-1] print "***Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
def generateGraph(self, widget, data): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() green = self.getData(playerids, sitenos) print _("Graph generated in: %s") %(time() - starttime) #Set axis labels and grid overlay properites self.ax.set_xlabel(_("Tournaments"), fontsize = 12) self.ax.set_ylabel("$", fontsize = 12) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) self.ax.plot(green, color='green', label=_('Tournaments') + ': %d\n' % len(green) + _('Profit') + ': $%.2f' % green[-1]) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #TODO: Do something useful like alert user else: self.ax.set_title(_("Tournament Results")) #Draw plot self.ax.plot(green, color='green', label=_('Tournaments') + ': %d\n' % len(green) + _('Profit') + ': $%.2f' % green[-1]) legend = self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) legend.draggable(True) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw()
def generateGraph(self, widget, data): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() games = self.filters.getGames() currencies = self.filters.getCurrencies() graphops = self.filters.getGraphOps() names = "" for i in ("show", "none"): if i in limits: limits.remove(i) # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) names = names + "\n" + _hname + " on " + site if not sitenos: # Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return if not limits: print _("No limits found") self.db.rollback() return # Set graph properties self.ax = self.fig.add_subplot(111) # Get graph data from DB starttime = time() (green, blue, red, orange) = self.getRingProfitGraph( playerids, sitenos, limits, games, currencies, graphops["dspin"] ) print _("Graph generated in: %s") % (time() - starttime) # Set axis labels and grid overlay properites self.ax.set_xlabel(_("Hands")) # SET LABEL FOR X AXIS self.ax.set_ylabel(graphops["dspin"]) self.ax.grid(color="g", linestyle=":", linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = [ 0.0, 0.0, 0.0, 0.0, 500.0, 1000.0, 900.0, 800.0, 700.0, 600.0, 500.0, 400.0, 300.0, 200.0, 100.0, 0.0, 500.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 875.0, 750.0, 625.0, 500.0, 375.0, 250.0, 125.0, 0.0, 0.0, 0.0, 0.0, 500.0, 1000.0, 900.0, 800.0, 700.0, 600.0, 500.0, 400.0, 300.0, 200.0, 100.0, 0.0, 500.0, 1000.0, 1000.0, ] red = [ 0.0, 0.0, 0.0, 0.0, 500.0, 1000.0, 900.0, 800.0, 700.0, 600.0, 500.0, 400.0, 300.0, 200.0, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 125.0, 250.0, 375.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 375.0, 250.0, 125.0, 0.0, 0.0, 0.0, 0.0, 500.0, 1000.0, 900.0, 800.0, 700.0, 600.0, 500.0, 400.0, 300.0, 200.0, 100.0, 0.0, 500.0, 1000.0, 1000.0, ] blue = [ 0.0, 0.0, 0.0, 0.0, 500.0, 1000.0, 900.0, 800.0, 700.0, 600.0, 500.0, 400.0, 300.0, 200.0, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 125.0, 250.0, 375.0, 500.0, 625.0, 750.0, 875.0, 1000.0, 875.0, 750.0, 625.0, 500.0, 375.0, 250.0, 125.0, 0.0, 0.0, 0.0, 0.0, 500.0, 1000.0, 900.0, 800.0, 700.0, 600.0, 500.0, 400.0, 300.0, 200.0, 100.0, 0.0, 500.0, 1000.0, 1000.0, ] self.ax.plot( green, color="green", label=_("Hands") + ": %d\n" % len(green) + _("Profit") + ": %.2f" % green[-1] ) self.ax.plot(blue, color="blue", label=_("Showdown") + ": $%.2f" % (blue[-1])) self.ax.plot(red, color="red", label=_("Non-showdown") + ": $%.2f" % (red[-1])) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() else: self.ax.set_title((_("Profit graph for ring games") + names)) # Draw plot if graphops["showdown"] == "ON": self.ax.plot(blue, color="blue", label=_("Showdown") + " (%s): %.2f" % (graphops["dspin"], blue[-1])) if graphops["nonshowdown"] == "ON": self.ax.plot(red, color="red", label=_("Non-showdown") + " (%s): %.2f" % (graphops["dspin"], red[-1])) if graphops["ev"] == "ON": self.ax.plot( orange, color="orange", label=_("All-in EV") + " (%s): %.2f" % (graphops["dspin"], orange[-1]) ) self.ax.plot( green, color="green", label=_("Hands") + ": %d\n" % len(green) + _("Profit") + ": (%s): %.2f" % (graphops["dspin"], green[-1]), ) # order legend, greenline on top handles, labels = self.ax.get_legend_handles_labels() handles = handles[-1:] + handles[:-1] labels = labels[-1:] + labels[:-1] legend = self.ax.legend( handles, labels, loc="upper left", fancybox=True, shadow=True, prop=FontProperties(size="smaller") ) legend.draggable(True) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw()
def generateGraph(self, widget, data): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() (green, dates, transfersAmount, transfersDate, transferType) = self.getData(playerids, sitenos) print _("Graph generated in: %s") %(time() - starttime) #Set axis labels and grid overlay properites self.ax.set_ylabel("$", fontsize = 12) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) self.ax.plot(green, color='green', label=_('Bankroll') + _('Profit') + ': $%.2f' % green[-1]) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #TODO: Do something useful like alert user else: self.ax.set_title(_("Bankroll Results")) useDates = True #nothing to draw if (len(green) == 0): return #Get the dates of the action (transfert / cg hand / tourney) #if it has no date, get the most ancient date and assume it's its one if dates[0] is None: i = 1 while i < len(dates) and type(dates[i]) is None: i = i+1 if i == len(dates): print "Wow wow wow : no dates in your whole database" useDates = False else: dates[0] = dates[i] #now, convert date to dateTime format if useDates: for i in range(0, len(dates)): if dates[i] is None: dates[i] = dates[i-1] #~else: #~dates[i] = datetime.datetime.strptime(dates[i], "%Y-%m-%d %H:%M:%S") for i in range(0, len(green)-1): beneficeSinceStart=green[i+1]-self.totalTransfer(dates[i+1], transfersAmount, transfersDate) mycolor = self.color(transferType[i+1], beneficeSinceStart) self.ax.plot([i,i+1], [green[i],green[i+1]], color=mycolor) #show date and gain only 5 times on X axis if (i % (len(green)/5) == 1): #the gain since start at this time if (mycolor=='cyan'): mycolor='green' self.ax.annotate('%.2f' % beneficeSinceStart, xy=(i, 0), color=mycolor, xycoords=('data', 'axes fraction'), xytext=(0, 18), textcoords='offset points', va='top', ha='left') #and show the date too if enabled if useDates: dateMMDD=datetime.datetime.strptime(dates[i], "%Y-%m-%d %H:%M:%S").strftime('%d/%m') self.ax.annotate(dateMMDD, xy=(i, 0), xycoords=('data', 'axes fraction'), xytext=(0, -18), textcoords='offset points', va='top', ha='left') #plot the last one and show the top corner legend i = len(green)-1 bankroll = float(green[i]) profit = bankroll if len(transfersAmount)>0: profit -= transfersAmount[len(transfersAmount)-1] self.ax.plot([i,i+1], [green[i],green[i]], color=self.color(transferType[i], beneficeSinceStart), label=_('Bankroll') + ': \$%.2f' % bankroll + '\n' + _('Profit') + ': \$%.2f' % profit) legend = self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) legend.draggable(True) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw()
def do_tip(widget, tip): _tip = Charset.to_utf8(tip) widget.set_tooltip_text(_tip)
def generateGraph(self, widget, data): try: self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() green = self.getData(playerids, sitenos) print _("Graph generated in: %s") %(time() - starttime) #Set axis labels and grid overlay properites self.ax.set_xlabel(_("Tournaments"), fontsize = 12) self.ax.set_ylabel("$", fontsize = 12) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) self.ax.plot(green, color='green', label=_('Tournaments: %d\nProfit: $%.2f') %(len(green), green[-1])) #self.ax.plot(blue, color='blue', label=_('Showdown: $%.2f') %(blue[-1])) #self.ax.plot(red, color='red', label=_('Non-showdown: $%.2f') %(red[-1])) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #TODO: Do something useful like alert user #print "No hands returned by graph query" else: self.ax.set_title(_("Tournament Results")) #Draw plot self.ax.plot(green, color='green', label=_('Tournaments: %d\nProfit: $%.2f') %(len(green), green[-1])) #self.ax.plot(blue, color='blue', label=_('Showdown: $%.2f') %(blue[-1])) #self.ax.plot(red, color='red', label=_('Non-showdown: $%.2f') %(red[-1])) if sys.version[0:3] == '2.5': self.ax.legend(loc='upper left', shadow=True, prop=FontProperties(size='smaller')) else: self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #self.exportButton.set_sensitive(True) except: err = traceback.extract_tb(sys.exc_info()[2])[-1] print _("Error:")+" "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
def generateGraph(self, widget, data): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() green = self.getData(playerids, sitenos) print _("Graph generated in: %s") % (time() - starttime) #Set axis labels and grid overlay properites self.ax.set_xlabel(_("Tournaments"), fontsize=12) self.ax.set_ylabel("$", fontsize=12) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) self.ax.plot(green, color='green', label=_('Tournaments') + ': %d\n' % len(green) + _('Profit') + ': $%.2f' % green[-1]) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #TODO: Do something useful like alert user else: self.ax.set_title(_("Tournament Results")) #Draw plot self.ax.plot(green, color='green', label=_('Tournaments') + ': %d\n' % len(green) + _('Profit') + ': $%.2f' % green[-1]) legend = self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) legend.draggable(True) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw()
def generateGraph(self, widget): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() games = self.filters.getGames() currencies = self.filters.getCurrencies() graphops = self.filters.getGraphOps() display_in = "$" if "$" in graphops else "BB" names = "" # Which sites are selected? for site in sites: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) names = names + "\n" + _hname + " on " + site if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return if not limits: print _("No limits found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() (green, blue, red, orange) = self.getRingProfitGraph(playerids, sitenos, limits, games, currencies, display_in) print _("Graph generated in: %s") % (time() - starttime) #Set axis labels and grid overlay properites self.ax.set_xlabel(_("Hands")) # SET LABEL FOR X AXIS self.ax.set_ylabel(display_in) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green is None or len(green) == 0: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) self.ax.plot(green, color='green', label=_('Hands') + ': %d\n' % len(green) + _('Profit') + ': %.2f' % green[-1]) self.ax.plot(blue, color='blue', label=_('Showdown') + ': $%.2f' % (blue[-1])) self.ax.plot(red, color='red', label=_('Non-showdown') + ': $%.2f' % (red[-1])) self.graphBox.addWidget(self.canvas) self.canvas.draw() else: self.ax.set_title((_("Profit graph for ring games") + names)) #Draw plot if 'showdown' in graphops: self.ax.plot(blue, color='blue', label=_('Showdown') + ' (%s): %.2f' % (display_in, blue[-1])) if 'nonshowdown' in graphops: self.ax.plot(red, color='red', label=_('Non-showdown') + ' (%s): %.2f' % (display_in, red[-1])) if 'ev' in graphops: self.ax.plot(orange, color='orange', label=_('All-in EV') + ' (%s): %.2f' % (display_in, orange[-1])) self.ax.plot(green, color='green', label=_('Hands') + ': %d\n' % len(green) + _('Profit') + ': (%s): %.2f' % (display_in, green[-1])) # order legend, greenline on top handles, labels = self.ax.get_legend_handles_labels() handles = handles[-1:] + handles[:-1] labels = labels[-1:] + labels[:-1] legend = self.ax.legend(handles, labels, loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) legend.draggable(True) self.graphBox.addWidget(self.canvas) self.canvas.draw()
def generateGraph(self, widget, data): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() games = self.filters.getGames() currencies = self.filters.getCurrencies() graphops = self.filters.getGraphOps() names = "" for i in ('show', 'none'): if i in limits: limits.remove(i) # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) names = names + "\n"+_hname + " on "+site if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return if not limits: print _("No limits found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() (green, blue, red, orange) = self.getRingProfitGraph(playerids, sitenos, limits, games, currencies, graphops['dspin']) print _("Graph generated in: %s") %(time() - starttime) #Set axis labels and grid overlay properites self.ax.set_xlabel(_("Hands")) # SET LABEL FOR X AXIS self.ax.set_ylabel(graphops['dspin']) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000.]) self.ax.plot(green, color='green', label=_('Hands') + ': %d\n' % len(green) + _('Profit') + ': %.2f' % green[-1]) self.ax.plot(blue, color='blue', label=_('Showdown') + ': $%.2f' %(blue[-1])) self.ax.plot(red, color='red', label=_('Non-showdown') + ': $%.2f' %(red[-1])) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() else: self.ax.set_title((_("Profit graph for ring games")+names)) #Draw plot self.ax.plot(green, color='green', label=_('Hands') + ': %d\n' % len(green) + _('Profit') + ': (%s): %.2f' % (graphops['dspin'], green[-1])) if graphops['showdown'] == 'ON': self.ax.plot(blue, color='blue', label=_('Showdown') + ' (%s): %.2f' %(graphops['dspin'], blue[-1])) if graphops['nonshowdown'] == 'ON': self.ax.plot(red, color='red', label=_('Non-showdown') + ' (%s): %.2f' %(graphops['dspin'], red[-1])) if graphops['ev'] == 'ON': self.ax.plot(orange, color='orange', label=_('All-in EV') + ' (%s): %.2f' %(graphops['dspin'], orange[-1])) if sys.version[0:3] == '2.5': self.ax.legend(loc='upper left', shadow=True, prop=FontProperties(size='smaller')) else: self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw()
def generateGraph(self, widget, data): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() currencies = self.filters.getCurrencies() # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() (green, datesXAbs) = self.getData(playerids, sitenos, currencies) print _("Graph generated in: %s") % (time() - starttime) currencyLabel = ','.join(['%s' % key for key in currencies.keys()]) #Set axis labels and grid overlay properites self.ax.set_ylabel(currencyLabel, fontsize=12) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) self.ax.plot(green, color='green', label=_('Tournaments') + ': %d\n' % len(green) + _('Profit') + '(' + currencyLabel + '): %.2f' % green[-1]) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #TODO: Do something useful like alert user else: self.ax.set_title(_("Tournament Results")) useDates = True #nothing to draw if (len(green) == 0): return #Get the dates of tourneys #if first tourney has no date, get the most ancient date and assume it's his one if datesXAbs[0] is None: i = 1 while i < len(datesXAbs) and type(datesXAbs[i]) is None: i = i + 1 if i == len(datesXAbs): print "Wow wow wow : no dates in your whole tourneys" useDates = False else: datesXAbs[0] = datesXAbs[i] #now convert date to dateTime format if useDates: for i in range(0, len(datesXAbs)): if datesXAbs[i] is None: datesXAbs[i] = datesXAbs[i - 1] else: datesXAbs[i] = datetime.datetime.strptime( datesXAbs[i], "%Y-%m-%d %H:%M:%S") datesXAbs[i] = datesXAbs[i].strftime('%d/%m') mycolor = 'red' if green[0] > 0: mycolor = 'green' self.ax.plot([0, 1], [0, green[0]], color=mycolor, label=_('Tournaments') + ': %d\n' % len(green) + _('Profit') + '(' + currencyLabel + '): %.2f' % green[-1]) for i in range(1, len(green)): final = green[i] - green[i - 1] mycolor = 'red' if (green[i] > 0): mycolor = 'green' self.ax.plot([i, i + 1], [green[i - 1], green[i]], color=mycolor) if (i % (len(green) / 5) == 0): gain = "" if (green[i] == 0): gain = "=" else: if (green[i] > 0): gain = "+" gain += str(green[i]) self.ax.annotate(gain, xy=(i, 0), color=mycolor, xycoords=('data', 'axes fraction'), xytext=(0, 18), textcoords='offset points', va='top', ha='left') if useDates: self.ax.annotate(datesXAbs[i], xy=(i, 0), xycoords=('data', 'axes fraction'), xytext=(0, -18), textcoords='offset points', va='top', ha='left') #~self.ax.axhline(0, color='black', lw=2) legend = self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) legend.draggable(True) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw()
def generateGraph(self, widget, data): try: self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() games = self.filters.getGames() graphops = self.filters.getGraphOps() names = "" for i in ('show', 'none'): if i in limits: limits.remove(i) # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) names = names + "\n" + _hname + " on " + site if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return if not limits: print _("No limits found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() (green, blue, red) = self.getRingProfitGraph(playerids, sitenos, limits, games, graphops['dspin']) print _("Graph generated in: %s") % (time() - starttime) #Set axis labels and grid overlay properites self.ax.set_xlabel(_("Hands"), fontsize=12) # SET LABEL FOR X AXIS self.ax.set_ylabel(graphops['dspin'], fontsize=12) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) self.ax.plot(green, color='green', label=_('Hands: %d\nProfit: (%s): %.2f') % (len(green), green[-1])) self.ax.plot(blue, color='blue', label=_('Showdown') + ': $%.2f' % (blue[-1])) self.ax.plot(red, color='red', label=_('Non-showdown') + ': $%.2f' % (red[-1])) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #TODO: Do something useful like alert user #print "No hands returned by graph query" else: self.ax.set_title((_("Profit graph for ring games") + names), fontsize=12) #Draw plot self.ax.plot(green, color='green', label=_('Hands: %d\nProfit: (%s): %.2f') % (len(green), graphops['dspin'], green[-1])) if graphops['showdown'] == 'ON': self.ax.plot(blue, color='blue', label=_('Showdown') + ' (%s): %.2f' % (graphops['dspin'], blue[-1])) if graphops['nonshowdown'] == 'ON': self.ax.plot(red, color='red', label=_('Non-showdown') + ' (%s): %.2f' % (graphops['dspin'], red[-1])) if sys.version[0:3] == '2.5': self.ax.legend(loc='upper left', shadow=True, prop=FontProperties(size='smaller')) else: self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() #self.exportButton.set_sensitive(True) except: err = traceback.extract_tb(sys.exc_info()[2])[-1] print _("Error:") + " " + err[2] + "(" + str(err[1]) + "): " + str( sys.exc_info()[1])
def generateGraph(self, widget, data): self.clearGraphData() sitenos = [] playerids = [] sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() games = self.filters.getGames() currencies = self.filters.getCurrencies() graphops = self.filters.getGraphOps() names = "" for i in ('show', 'none'): if i in limits: limits.remove(i) # Which sites are selected? for site in sites: if sites[site] == True: sitenos.append(siteids[site]) _hname = Charset.to_utf8(heroes[site]) result = self.db.get_player_id(self.conf, site, _hname) if result is not None: playerids.append(int(result)) names = names + "\n" + _hname + " on " + site if not sitenos: #Should probably pop up here. print _("No sites selected - defaulting to PokerStars") self.db.rollback() return if not playerids: print _("No player ids found") self.db.rollback() return if not limits: print _("No limits found") self.db.rollback() return #Set graph properties self.ax = self.fig.add_subplot(111) #Get graph data from DB starttime = time() (green, blue, red, orange) = self.getRingProfitGraph(playerids, sitenos, limits, games, currencies, graphops['dspin']) print _("Graph generated in: %s") % (time() - starttime) #Set axis labels and grid overlay properites self.ax.set_xlabel(_("Hands")) # SET LABEL FOR X AXIS self.ax.set_ylabel(graphops['dspin']) self.ax.grid(color='g', linestyle=':', linewidth=0.2) if green == None or green == []: self.ax.set_title(_("No Data for Player(s) Found")) green = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) red = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 500., 500., 500., 500., 500., 500., 500., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) blue = ([ 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 0., 0., 0., 0., 0., 0., 125., 250., 375., 500., 625., 750., 875., 1000., 875., 750., 625., 500., 375., 250., 125., 0., 0., 0., 0., 500., 1000., 900., 800., 700., 600., 500., 400., 300., 200., 100., 0., 500., 1000., 1000. ]) self.ax.plot(green, color='green', label=_('Hands') + ': %d\n' % len(green) + _('Profit') + ': %.2f' % green[-1]) self.ax.plot(blue, color='blue', label=_('Showdown') + ': $%.2f' % (blue[-1])) self.ax.plot(red, color='red', label=_('Non-showdown') + ': $%.2f' % (red[-1])) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw() else: self.ax.set_title((_("Profit graph for ring games") + names)) #Draw plot self.ax.plot(green, color='green', label=_('Hands') + ': %d\n' % len(green) + _('Profit') + ': (%s): %.2f' % (graphops['dspin'], green[-1])) if graphops['showdown'] == 'ON': self.ax.plot(blue, color='blue', label=_('Showdown') + ' (%s): %.2f' % (graphops['dspin'], blue[-1])) if graphops['nonshowdown'] == 'ON': self.ax.plot(red, color='red', label=_('Non-showdown') + ' (%s): %.2f' % (graphops['dspin'], red[-1])) if graphops['ev'] == 'ON': self.ax.plot(orange, color='orange', label=_('All-in EV') + ' (%s): %.2f' % (graphops['dspin'], orange[-1])) if sys.version[0:3] == '2.5': self.ax.legend(loc='upper left', shadow=True, prop=FontProperties(size='smaller')) else: self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) self.graphBox.add(self.canvas) self.canvas.show() self.canvas.draw()