class Settings(QWidget): def __init__(self, mainWindows): QWidget.__init__(self) uic.loadUi(directory + "/../ui/settings.ui", self) self.mainWindows = mainWindows mainWindows.diconnectActions() self.mainWindows.setWindowTitle("Opciones | Betcon v" + mainWindows.version) self.btnAccept.clicked.connect(self.accept) self.btnCancel.clicked.connect(self.cancel) self.config = LibYaml() self.txtPercentage.setValue(self.config.stake["percentage"]) self.cmbOne.setCurrentIndex(self.config.stake["type"]) self.txtStake.setValue(self.config.stake["stake"]) if self.config.stake["type"] == 0: self.txtStake.setEnabled(False) self.cmbOne.activated.connect(self.updateOne) self.btnCalc.clicked.connect(self.calcBank) def updateOne(self): result = self.cmbOne.currentIndex() self.txtStake.setEnabled(False) if result == 0 else self.txtStake.setEnabled(True) def calcBank(self): bd = Bbdd() bookies = Bookie.sumAll() bonus = Bookie.sumBonus() # CC cc = bd.select("bank", None, "id=1", "bank") cc = cc[0][0] # Paypal paypal = bd.select("bank", None, "id=2", "bank") paypal = paypal[0][0] # SKRILL skrill = bd.select("bank", None, "id=3", "bank") skrill = skrill[0][0] total = "{0:.2f}".format(cc + paypal + skrill + bonus + bookies) total = float(total) * (self.txtPercentage.value() * 0.01) self.txtStake.setValue(float(total)) def close(self): self.mainWindows.enableTools() self.mainWindows.setCentralWidget(Bets(self.mainWindows)) def cancel(self): self.close() def accept(self): self.config.stake["percentage"] = str_to_float(self.txtPercentage.text()[:-1]) self.config.stake["type"] = self.cmbOne.currentIndex() self.config.stake["stake"] = str_to_float(self.txtStake.text()[:-1]) self.config.save() self.close()
def __init__(self, mainWindows): QWidget.__init__(self) uic.loadUi(directory + "/../ui/settings.ui", self) self.mainWindows = mainWindows mainWindows.diconnectActions() self.mainWindows.setWindowTitle("Opciones | Betcon v" + mainWindows.version) self.btnAccept.clicked.connect(self.accept) self.btnCancel.clicked.connect(self.cancel) self.config = LibYaml() self.txtPercentage.setValue(self.config.stake["percentage"]) self.cmbOne.setCurrentIndex(self.config.stake["type"]) self.txtStake.setValue(self.config.stake["stake"]) if self.config.stake["type"] == 0: self.txtStake.setEnabled(False) self.cmbOne.activated.connect(self.updateOne) self.btnCalc.clicked.connect(self.calcBank)
def __init__(self, mainWindows): QWidget.__init__(self) uic.loadUi(directory + "/../ui/tipsters_month.ui", self) gettext.textdomain("betcon") gettext.bindtextdomain("betcon", "../lang/mo" + mainWindows.lang) gettext.bindtextdomain("betcon", "/usr/share/locale" + mainWindows.lang) self.mainWindows = mainWindows mainWindows.aNew.triggered.connect(mainWindows.newTipsterMonth) self.mainWindows.setWindowTitle( _("Tipsters - Payment history") + " | Betcon v" + mainWindows.version) self.treeMain.header().hideSection(0) self.treeConjunta.header().hideSection(0) self.coin = LibYaml().interface["coin"] self.translate() self.initTree() self.treeMain.itemSelectionChanged.connect(self.changeItem) self.treeConjunta.itemSelectionChanged.connect(self.changeItemConjunta) self.mainWindows.aEdit.triggered.connect(self.editItem) self.mainWindows.aRemove.triggered.connect(self.deleteItem) self.mainWindows.enableActionConjunta(False) self.mainWindows.aEditConjunta.triggered.connect(self.editConjunta) self.mainWindows.aDeleteConjunta.triggered.connect(self.deleteConjunta) self.itemSelected = -1 self.itemConjunta = -1
def __init__(self, mainWindows): QWidget.__init__(self) uic.loadUi(directory + "/../ui/bets.ui", self) gettext.textdomain("betcon") gettext.bindtextdomain("betcon", "../lang/mo" + mainWindows.lang) gettext.bindtextdomain("betcon", "/usr/share/locale" + mainWindows.lang) self.mainWindows = mainWindows mainWindows.diconnectActions() mainWindows.aNew.triggered.connect(mainWindows.newBet) self.mainWindows.setWindowTitle(_("Home") + " | Betcon v" + mainWindows.version) header = [" ", "index", _("Date"), _("Sport"), _("Competition"), _("Region"), _("Local Team"), _("Away Team"), _("Pick"), _("Bookie"), _("Market"), _("Tipster"), _("Stake"), _("Stake 1"), _("Bet"), _("Quota"), _("Result"), _("Profit")] self.lblYear.setText(_("Year")) self.lblMonth.setText(_("Month")) self.coin = LibYaml().interface["coin"] self.treeMain.header().hideSection(1) try: self.initData() except: print("No hay datos") self.treeMain.itemSelectionChanged.connect(self.changeItem) self.mainWindows.aEdit.triggered.connect(self.editItem) self.mainWindows.aRemove.triggered.connect(self.deleteItem) self.cmbYear.activated.connect(self.updateMonths) self.cmbMonth.activated.connect(self.initTree) self.itemSelected = -1 self.indexSelected = -1 self.treeMain.setHeaderLabels(header)
def __init__(self, mainWindows): QWidget.__init__(self) uic.loadUi(directory + "/../ui/settings.ui", self) gettext.textdomain("betcon") gettext.bindtextdomain("betcon", "../lang/mo" + mainWindows.lang) gettext.bindtextdomain("betcon", "/usr/share/locale" + mainWindows.lang) self.mainWindows = mainWindows mainWindows.diconnectActions() self.mainWindows.setWindowTitle(_("Options") + " | Betcon v" + mainWindows.version) self.translate() self.btnAccept.clicked.connect(self.accept) self.btnCancel.clicked.connect(self.cancel) # TODO Al cargar el formulario debe actualiza el combobox con el valor del yml self.cmbLanguage.addItem("Deutsch", "de") self.cmbLanguage.addItem("English", "en") self.cmbLanguage.addItem("Español", "es") self.cmbLanguage.addItem("Kurdî", "ki") self.cmbLanguage.addItem("Português do Brasil", "pt_BR") self.cmbLanguage.addItem("Türk", "tr") self.config = LibYaml() self.txtPercentage.setValue(float(self.config.stake["percentage"])) self.cmbOne.setCurrentIndex(self.config.stake["type"]) self.txtStake.setValue(float(self.config.stake["stake"])) if self.config.stake["type"] == 0: self.txtStake.setEnabled(False) self.cmbOne.activated.connect(self.updateOne) self.btnCalc.clicked.connect(self.calcBank) self.txtCoin.setText(self.config.interface["coin"]) if self.config.interface['bookieCountry'] == 'Y': self.chkCountryYes.setChecked(True) else: self.chkCountryNo.setChecked(True) langIndex = {"de": 0, "en": 1, "es": 2, "ki": 3, "pt_BR": 4, "tr": 5} try: self.cmbLanguage.setCurrentIndex(langIndex[self.config.interface['lang']]) except Exception: self.cmbLanguage.setCurrentIndex(langIndex["es"]) if platform.system() == 'Linux': self.cmbLanguage.setEnabled(False)
def __init__(self, mainWindows): QWidget.__init__(self) uic.loadUi(directory + "/../ui/new_bank.ui", self) gettext.textdomain("betcon") gettext.bindtextdomain("betcon", "../lang/mo" + mainWindows.lang) gettext.bindtextdomain("betcon", "/usr/share/locale" + mainWindows.lang) self.mainWindows = mainWindows self.btnAccept.clicked.connect(self.accept) self.btnCancel.clicked.connect(self.cancel) self.mainWindows.setWindowTitle( _("New Movement") + " | Betcon v" + mainWindows.version) self.coin = LibYaml().interface["coin"] self.initData() self.translate()
def __init__(self, mainWindows): QWidget.__init__(self) uic.loadUi(directory + "/../ui/stats.ui", self) gettext.textdomain("betcon") gettext.bindtextdomain("betcon", "../lang/mo" + mainWindows.lang) gettext.bindtextdomain("betcon", "/usr/share/locale" + mainWindows.lang) self.mainWindows = mainWindows self.mainWindows.setWindowTitle( _("Stats") + " | Betcon v" + mainWindows.version) self.coin = LibYaml().interface["coin"] self.translate() self.initData() self.cmbYear.activated.connect(self.updateMonths) self.cmbMonth.activated.connect(self.updateDays) self.cmbDay.activated.connect(self.updateStats)
def __init__(self, mainWindows): QWidget.__init__(self) uic.loadUi(directory + "/../ui/bonus.ui", self) gettext.textdomain("betcon") gettext.bindtextdomain("betcon", "../lang/mo" + mainWindows.lang) gettext.bindtextdomain("betcon", "/usr/share/locale" + mainWindows.lang) self.mainWindows = mainWindows mainWindows.diconnectActions() mainWindows.aNew.triggered.connect(mainWindows.newBonus) self.mainWindows.setWindowTitle(_("Bonus") + " | Betcon v" + mainWindows.version) self.treeMain.header().hideSection(1) self.coin = LibYaml().interface["coin"] self.initTree() self.treeMain.itemSelectionChanged.connect(self.changeItem) self.mainWindows.aEdit.triggered.connect(self.editItem) self.mainWindows.aRemove.triggered.connect(self.deleteItem) self.itemSelected = -1 self.translate()
def calcStake(self): self.config = LibYaml() if self.config.stake["type"] == 0: bd = Bbdd() bookies = Bookie.sumAll() bonus = Bookie.sumBonus() # CC cc = bd.select("bank", None, "id=1", "bank") cc = cc[0][0] # Paypal paypal = bd.select("bank", None, "id=2", "bank") paypal = paypal[0][0] # SKRILL skrill = bd.select("bank", None, "id=3", "bank") skrill = skrill[0][0] total = "{0:.2f}".format(cc + paypal + skrill + bonus + bookies) total = float(total) * (self.config.stake["percentage"] * 0.01) self.txtOne.setValue(float(total)) else: self.txtOne.setValue(self.config.stake["stake"])
def __init__(self): QMainWindow.__init__(self) uic.loadUi(directory + "/../ui/wmain.ui", self) if platform.system() != 'Linux': self.lang = "/" + LibYaml().interface["lang"] else: self.lang = "" gettext.textdomain("betcon") gettext.bindtextdomain("betcon", "../lang/mo" + self.lang) gettext.bindtextdomain("betcon", "/usr/share/locale" + self.lang) self.showMaximized() self.enableTools() archivo = open(directory + "/version.txt") self.version = archivo.readline() self.setWindowTitle(_("Home") + " | Betcon v" + self.version) if os.path.isfile("/usr/share/pixmaps/betcon.png"): image = "/usr/share/pixmaps/betcon.png" else: image = directory + '/../resources/icon.png' self.setWindowIcon(QIcon(image)) self.aInicio.triggered.connect(self.home) self.aInicio.setText(_("Home")) self.aRegion.triggered.connect(self.regions) self.aRegion.setText(_("Regions")) self.aCompetition.triggered.connect(self.competitions) self.aCompetition.setText(_("Competitions")) self.aSport.triggered.connect(self.sports) self.aSport.setText(_("Sports")) self.aBookie.triggered.connect(self.bookies) self.aBookie.setText(_("Bookies")) self.aMarket.triggered.connect(self.markets) self.aMarket.setText(_("Markets")) self.aTipster.triggered.connect(self.tipsters) self.aTipster.setText(_("Tipsters")) self.aStat.triggered.connect(self.stats) self.aStat.setText(_("Stats")) self.aBank.triggered.connect(self.banks) self.aBank.setText(_("Bank")) self.aBonus.triggered.connect(self.bonus) self.aBonus.setText(_("Bonus")) self.aTipsterMonth.triggered.connect(self.tipstersMonth) self.aTipsterMonth.setText(_("Payment history")) self.aStatsGeneral.triggered.connect(self.stats) self.aStatsGeneral.setText(_("General")) self.aStatsTipster.triggered.connect(self.statsTipster) self.aStatsTipster.setText(_("Tipsters")) self.aStatsBookie.triggered.connect(self.statsBookie) self.aStatsBookie.setText(_("Bookies")) self.aStatsMarket.triggered.connect(self.statsMarket) self.aStatsMarket.setText(_("Markets")) self.aStatsRegion.triggered.connect(self.statsRegion) self.aStatsRegion.setText(_("Regions")) self.aStatsSport.triggered.connect(self.statsSport) self.aStatsSport.setText(_("Sports")) self.aStatsStake.triggered.connect(self.statsStake) self.aStatsStake.setText(_("Stake")) self.aAddMoney.triggered.connect(self.addMoney) self.aAddMoney.setText(_("Add/Withdraw funds")) self.aClose.triggered.connect(self.close) self.aClose.setText(_("Close")) self.aAbout.triggered.connect(self.about) self.aAbout.setText(_("About...")) self.aSettings.triggered.connect(self.settings) self.aSettings.setText(_("Settings")) self.aDonate.triggered.connect(self.donate) self.aDonate.setText(_("Donate")) self.aNewConjunta.triggered.connect(self.newConjunta) self.aNewConjunta.setText(_("New joint purchase")) self.aExport.triggered.connect(self.export) self.aExport.setText(_("Export")) self.aImport.triggered.connect(self.imports) self.aImport.setText(_("Import")) self.aNew.setText(_("New")) self.aEdit.setText(_("Edit")) self.aRemove.setText(_("Delete")) self.aEditConjunta.setText(_("Edit joint purchase")) self.aDeleteConjunta.setText(_("Delete joint purchase")) self.menuArchivo.setTitle(_("File")) self.menuAyuda.setTitle(_("Help")) self.setCentralWidget(Bets(self))
def initData(self): # dtDate sDate = datetime.now().strftime('%Y-%m-%d %H:%M:%S') date = QDateTime.fromString(sDate, "yyyy-MM-dd hh:mm:ss") self.dtDate.setDateTime(date) # cmbSport bd = Bbdd() data = bd.select("sport", "name") self.sportIndexToId = {} index = 0 for i in data: id = i[0] name = i[1] self.cmbSport.addItem(name) self.sportIndexToId[index] = id index += 1 # cmbBookie data = bd.select("bookie", "name") self.bookieIndexToId = {} index = 0 for i in data: id = i[0] name = i[1] country = i[2] if LibYaml().interface['bookieCountry'] == 'Y': name += ' (' + country + ')' self.cmbBookie.addItem(name) self.bookieIndexToId[index] = id index += 1 # cmbMarket data = bd.select("market", "name") self.marketIndexToId = {} index = 0 for i in data: id = i[0] name = i[1] self.cmbMarket.addItem(name) self.marketIndexToId[index] = id index += 1 # cmbTipster data = bd.select("tipster", "name") self.tipsterIndexToId = {} index = 0 for i in data: id = i[0] name = i[1] self.cmbTipster.addItem(name) self.tipsterIndexToId[index] = id index += 1 self.players = bd.executeQuery("SELECT player1 as player FROM bet UNION SELECT player2 as player FROM bet ORDER BY player") self.players = [row[0] for row in self.players] self.txtPlayer1.addItems(self.players) self.txtPlayer2.addItems(self.players) bd.close() # cmbCompetition self.setRegion() #Combined self.contComb = 0 self.dates = [] self.sports = [] self.regions = [] self.competitions = [] self.players1 = [] self.players2 = [] self.picks = [] self.results = [] self.buttons = [] self.regionIndexToIdCmb = [] self.competitionIndexToIdCmb = [] self.calcStake()
class LibStats: coin = LibYaml().interface["coin"] @staticmethod def getYears(): years = Bbdd.getYearMonth("bet") months = { "01": _("January"), "02": _("February"), "03": _("March"), "04": _("April"), "05": _("May"), "06": _("June"), "07": _("July"), "08": _("August"), "09": _("September"), "10": _("October"), "11": _("November"), "12": _("December") } return years, months @staticmethod def getDaysOfMonth(year, month): days = Bbdd.getDaysOfMonth("bet", year, month) return days @staticmethod def getTipster(year=None, month=None): if year is not None: date = str(year) + "-" + str(month) sql = 'select tipster.name, sport.name, ' \ '(SELECT count(*) from bet as b1 WHERE b1.result in (1, 4) ' \ 'and b1.tipster = bet.tipster and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as acierto, ' \ '(SELECT count(*) from bet as b1 WHERE b1.result in (2, 5) and b1.tipster = bet.tipster ' \ 'and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as fallo, (SELECT SUM(profit) ' \ 'from bet as b1 WHERE b1.result <> 0 and b1.tipster = bet.tipster and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as prof, count(*), ' \ 'SUM(bet), avg(stake), avg(quota) from bet, tipster, sport WHERE bet.tipster=tipster.id ' \ 'and bet.sport=sport.id and bet.date LIKE "' + date + '%" GROUP BY bet.tipster,bet.sport ' else: sql = 'SELECT tipster.name, sport.name, (SELECT count(*) FROM bet AS b1 WHERE b1.result IN ' \ '(1, 4) AND b1.tipster = bet.tipster AND b1.sport=bet.sport) AS acierto, ' \ '(SELECT count(*) FROM bet AS b1 WHERE b1.result IN (2, 5) AND ' \ 'b1.tipster = bet.tipster AND b1.sport=bet.sport) AS fallo, (SELECT SUM(profit) ' \ 'FROM bet AS b1 WHERE b1.result <> 0 AND b1.tipster = bet.tipster AND b1.sport = bet.sport) AS prof, count(*), ' \ 'SUM(bet), avg(stake), avg(quota) FROM bet, tipster, sport ' \ 'WHERE bet.tipster=tipster.id AND bet.sport=sport.id GROUP BY bet.tipster,bet.sport' bd = Bbdd() datasql = bd.executeQuery(sql) bd.close() data = [] for i in datasql: row = [] if i[4] is None: continue row.append(i[0]) # Tipster row.append(i[1]) # Sports row.append(str(i[5])) # Number of bets try: win = i[2] / (i[2] + i[3]) # Percentage of win bet except ZeroDivisionError: win = 0 win = win * 100 row.append("{0:.2f}%".format(round((win), 2))) row.append("{0:.2f}".format(round( (i[6]), 2)) + LibStats.coin) # Money bet row.append("{0:.2f}".format(round( (i[4]), 2)) + LibStats.coin) # Profit row.append("{0:.2f}".format(round((i[7]), 2))) # Average Stake row.append("{0:.2f}".format(round((i[8]), 2))) # Average Quota data.append(row) return data @staticmethod def getBookie(year=None, month=None): if year is not None: date = str(year) + "-" + str(month) sql = 'select bookie.name, (SELECT count(*) from bet as b1 WHERE b1.result in ' \ '(1, 4) and b1.bookie = bet.bookie and b1.date LIKE "' + date + '%") as acierto, ' \ '(SELECT count(*) from bet as b1 WHERE b1.result in (2, 5) and ' \ 'b1.bookie = bet.bookie and b1.date LIKE "' + date + '%") as fallo, (SELECT SUM(profit) ' \ 'from bet as b1 WHERE b1.result <> 0 and b1.bookie = bet.bookie and b1.date LIKE "' + date + '%") as prof, count(*), ' \ 'SUM(bet), avg(stake), avg(quota) from bet, bookie ' \ 'WHERE bet.bookie=bookie.id and bet.date LIKE "' + date + '%" GROUP BY bet.bookie' else: sql = 'select bookie.name, (SELECT count(*) from bet as b1 WHERE b1.result in (1, 4)' \ ' and b1.bookie = bet.bookie) as acierto, (SELECT count(*) from bet as b1 WHERE b1.result in ' \ '(2, 5) and b1.bookie = bet.bookie) as fallo, ' \ '(SELECT SUM(profit) from bet as b1 WHERE b1.result <> 0 and' \ ' b1.bookie = bet.bookie) as prof, count(*), SUM(bet), avg(stake), ' \ 'avg(quota) from bet, bookie WHERE bet.bookie=bookie.id GROUP BY bet.bookie' bd = Bbdd() datasql = bd.executeQuery(sql) bd.close() data = [] for i in datasql: if i[3] is None: continue row = [] row.append(i[0]) # Name row.append(str(i[4])) # Number of bets try: win = i[1] / (i[1] + i[2]) # Percentage of win bet except ZeroDivisionError: win = 0 win = win * 100 win = round(win, 2) row.append("{0:.2f}%".format(round((win), 2))) row.append("{0:.2f}".format(round( (i[5]), 2)) + LibStats.coin) # Money bet row.append("{0:.2f}".format(round( (i[3]), 2)) + LibStats.coin) # Profit row.append("{0:.2f}".format(round((i[6]), 2))) # Average Stake row.append("{0:.2f}".format(round((i[7]), 2))) # Average Quota data.append(row) return data @staticmethod def getSport(year=None, month=None): if year is not None: date = str(year) + "-" + str(month) sql = 'select sport.name, (SELECT count(*) from bet as b1 WHERE b1.result in ' \ '(1, 4) and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as acierto, ' \ '(SELECT count(*) from bet as b1 WHERE b1.result in (2, 5) and ' \ 'b1.sport=bet.sport and b1.date LIKE "' + date + '%") as fallo, (SELECT SUM(profit) ' \ 'from bet as b1 WHERE b1.result <> 0 and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as prof, count(*), ' \ 'SUM(bet), avg(stake), avg(quota) from bet, sport ' \ 'WHERE bet.sport=sport.id and bet.date LIKE "' + date + '%" GROUP BY bet.sport' else: sql = 'select sport.name, (SELECT count(*) from bet as b1 WHERE b1.result in (1, 4)' \ ' and b1.sport = bet.sport) as acierto, (SELECT count(*) from bet as b1 WHERE b1.result in ' \ '(2, 5) and b1.sport = bet.sport) as fallo, ' \ '(SELECT SUM(profit) from bet as b1 WHERE b1.result <> 0 and' \ ' b1.sport = bet.sport) as prof, count(*), SUM(bet), avg(stake), ' \ 'avg(quota) from bet, sport WHERE bet.sport=sport.id GROUP BY bet.sport' bd = Bbdd() datasql = bd.executeQuery(sql) bd.close() data = [] for i in datasql: if i[3] is None: continue row = [] row.append(i[0]) # Name row.append(str(i[4])) # Number of bets try: win = i[1] / (i[1] + i[2]) # Percentage of win bet except ZeroDivisionError: win = 0 win = win * 100 win = round(win, 2) row.append("{0:.2f}%".format(round(win, 2))) row.append("{0:.2f}".format(round( (i[5]), 2)) + LibStats.coin) # Money bet row.append("{0:.2f}".format(round( (i[3]), 2)) + LibStats.coin) # Profit row.append("{0:.2f}".format(round((i[6]), 2))) # Average Stake row.append("{0:.2f}".format(round((i[7]), 2))) # Average Quota data.append(row) return data @staticmethod def getRegion(year=None, month=None): if year is not None: date = str(year) + "-" + str(month) sql = 'select region.name, sport.name, ' \ '(SELECT count(*) from bet as b1 WHERE b1.result in (1, 4) ' \ 'and b1.region = bet.region and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as acierto, ' \ '(SELECT count(*) from bet as b1 WHERE b1.result in (2, 5) and b1.region = bet.region ' \ 'and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as fallo, (SELECT SUM(profit) ' \ 'from bet as b1 WHERE b1.result <> 0 and b1.region = bet.region and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as prof, count(*), ' \ 'SUM(bet), avg(stake), avg(quota) from bet, region, sport WHERE bet.region=region.id ' \ 'and bet.sport=sport.id and bet.date LIKE "' + date + '%" GROUP BY bet.region,bet.sport ' else: sql = 'SELECT region.name, sport.name, (SELECT count(*) FROM bet AS b1 WHERE b1.result IN ' \ '(1, 4) AND b1.region = bet.region AND b1.sport=bet.sport) AS acierto, ' \ '(SELECT count(*) FROM bet AS b1 WHERE b1.result IN (2, 5) AND ' \ 'b1.region = bet.region AND b1.sport=bet.sport) AS fallo, (SELECT SUM(profit) ' \ 'FROM bet AS b1 WHERE b1.result <> 0 AND b1.region = bet.region AND b1.sport = bet.sport) AS prof, count(*), ' \ 'SUM(bet), avg(stake), avg(quota) FROM bet, region, sport ' \ 'WHERE bet.region=region.id AND bet.sport=sport.id GROUP BY bet.region, bet.sport' bd = Bbdd() datasql = bd.executeQuery(sql) bd.close() data = [] for i in datasql: if i[4] is None: continue row = [] row.append(i[0]) # Region row.append(i[1]) # Sports row.append(str(i[5])) # Number of bets try: win = i[2] / (i[2] + i[3]) # Percentage of win bet except ZeroDivisionError: win = 0 win = win * 100 row.append("{0:.2f}%".format(round(win, 2))) row.append("{0:.2f}".format(round( (i[6]), 2)) + LibStats.coin) # Money bet row.append("{0:.2f}".format(round( (i[4]), 2)) + LibStats.coin) # Profit row.append("{0:.2f}".format(round((i[7]), 2))) # Average Stake row.append("{0:.2f}".format(round((i[8]), 2))) # Average Quota data.append(row) return data @staticmethod def getMarket(year=None, month=None): if year is not None: date = str(year) + "-" + str(month) sql = 'select market.name, sport.name, ' \ '(SELECT count(*) from bet as b1 WHERE b1.result in (1, 4) ' \ 'and b1.market = bet.market and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as acierto, ' \ '(SELECT count(*) from bet as b1 WHERE b1.result in (2, 5) and b1.market = bet.market ' \ 'and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as fallo, (SELECT SUM(profit) ' \ 'from bet as b1 WHERE b1.result <> 0 and b1.market = bet.market and b1.sport=bet.sport and b1.date LIKE "' + date + '%") as prof, count(*), ' \ 'SUM(bet), avg(stake), avg(quota) from bet, market, sport WHERE bet.market=market.id ' \ 'and bet.sport=sport.id and bet.date LIKE "' + date + '%" GROUP BY bet.market, bet.sport ' else: sql = 'SELECT market.name, sport.name, (SELECT count(*) FROM bet AS b1 WHERE b1.result IN ' \ '(1, 4) AND b1.market = bet.market AND b1.sport=bet.sport) AS acierto, ' \ '(SELECT count(*) FROM bet AS b1 WHERE b1.result IN (2, 5) AND ' \ 'b1.market = bet.market AND b1.sport=bet.sport) AS fallo, (SELECT SUM(profit) ' \ 'FROM bet AS b1 WHERE b1.result <> 0 AND b1.market = bet.market AND b1.sport = bet.sport) AS prof, count(*), ' \ 'SUM(bet), avg(stake), avg(quota) FROM bet, market, sport ' \ 'WHERE bet.market=market.id AND bet.sport=sport.id GROUP BY bet.market, bet.sport' bd = Bbdd() datasql = bd.executeQuery(sql) bd.close() data = [] for i in datasql: if i[4] is None: continue row = [] row.append(i[0]) # Region row.append(i[1]) # Sports row.append(str(i[5])) # Number of bets try: win = i[2] / (i[2] + i[3]) # Percentage of win bet except ZeroDivisionError: win = 0 win = win * 100 row.append("{0:.2f}%".format(round(win, 2))) row.append("{0:.2f}".format(round( (i[6]), 2)) + LibStats.coin) # Money bet row.append("{0:.2f}".format(round( (i[4]), 2)) + LibStats.coin) # Profit row.append("{0:.2f}".format(round((i[7]), 2))) # Average Stake row.append("{0:.2f}".format(round((i[8]), 2))) # Average Quota data.append(row) return data @staticmethod def getStake(year=None, month=None): if year is not None: date = str(year) + "-" + str(month) sql = 'select bet.stake, (SELECT count(*) from bet as b1 WHERE b1.result in ' \ '(1, 4) and b1.stake=bet.stake and b1.date LIKE "' + date + '%") as acierto, ' \ '(SELECT count(*) from bet as b1 WHERE b1.result in (2, 5) and ' \ 'b1.stake=bet.stake and b1.date LIKE "' + date + '%") as fallo, (SELECT SUM(profit) ' \ 'from bet as b1 WHERE b1.result <> 0 and b1.stake=bet.stake and b1.date LIKE "' + date + '%") as prof, count(*), ' \ 'SUM(bet), avg(quota) from bet WHERE bet.date LIKE "' + date + '%" GROUP BY bet.stake' else: sql = 'select bet.stake, (SELECT count(*) from bet as b1 WHERE b1.result in (1, 4)' \ ' and b1.stake = bet.stake) as acierto, (SELECT count(*) from bet as b1 WHERE b1.result in ' \ '(2, 5) and b1.stake = bet.stake) as fallo, ' \ '(SELECT SUM(profit) from bet as b1 WHERE b1.result <> 0 and' \ ' b1.stake = bet.stake) as prof, count(*), SUM(bet), ' \ 'avg(quota) from bet GROUP BY bet.stake' bd = Bbdd() datasql = bd.executeQuery(sql) bd.close() data = [] for i in datasql: if i[3] is None: continue row = [] row.append(str(i[0])) # Stake row.append(str(i[4])) # Number of bets try: win = i[1] / (i[1] + i[2]) # Percentage of win bet except ZeroDivisionError: win = 0 win = win * 100 row.append("{0:.2f}%".format(round(win, 2))) row.append("{0:.2f}".format(round( (i[5]), 2)) + LibStats.coin) # Money bet row.append("{0:.2f}".format(round( (i[3]), 2)) + LibStats.coin) # Profit row.append("{0:.2f}".format(round((i[6]), 2))) # Average Quota data.append(row) return data @staticmethod def getMonth(year=None, month=None, day=None): date = str(year) if month is not None and month is not "": date += "-" + str(month) if day is not None and day is not "": date += "-" + day sql = 'select SUM(bet), ' \ '(select SUM(profit) from bet as b1 WHERE profit>0 AND b1.date LIKE "' + date + '%"), ' \ '(select SUM(profit) from bet as b1 WHERE profit<0 AND b1.date LIKE "' + date + '%"), ' \ 'SUM(profit), (select SUM(bet) from bet as b1 WHERE b1.result=0 AND bet.date LIKE "' + date + '%"), ' \ 'AVG(quota), count(bet), (select COUNT(*) from bet as b1 WHERE profit>0 AND b1.date LIKE "' + date + '%"), ' \ '(select count(*) from bet as b1 WHERE profit<0 AND b1.result<>0 AND b1.date LIKE "' + date + '%"),' \ '(select count(*) from bet as b1 WHERE profit=0 AND b1.date LIKE "' + date + '%"), AVG(bet)' \ ' from bet WHERE bet.date LIKE "' + date + '%"' bd = Bbdd() datasql = bd.executeQuery(sql) bd.close() bonus = Bookie.sumBonus("date LIKE '" + date + "%'") datasql = datasql[0] if bonus is None: bonus = 0 if datasql[0] == 0: return [0, 0, 0, 0, 0, "0%", 0, 0, 0, 0, 0, "0%", 0] yi = "{0:.2f}%".format( round(((datasql[3] + bonus) / datasql[0]) * 100, 2)) quota = float("{0:.2f}".format(datasql[5], 2)) bet = float("{0:.2f}".format(datasql[10], 2)) aciertos = "{0:.2f}%".format(round((datasql[7] / datasql[6]) * 100, 2)) data0 = "{0:.2f}".format(round(datasql[0], 2)) data1 = 0.0 if datasql[1] is None else "{0:.2f}".format( round(datasql[1] + bonus, 2)) data2 = 0.0 if datasql[2] is None else "{0:.2f}".format( round(datasql[2], 2)) data3 = 0.0 if datasql[3] is None else "{0:.2f}".format( round(datasql[3] + bonus, 2)) data4 = 0.0 if datasql[4] is None else "{0:.2f}".format( round(datasql[4], 2)) data = [ data0, data1, data2, data3, data4, yi, quota, datasql[6], datasql[7], datasql[8], datasql[9], aciertos, bet ] return data
class Settings(QWidget): def __init__(self, mainWindows): QWidget.__init__(self) uic.loadUi(directory + "/../ui/settings.ui", self) gettext.textdomain("betcon") gettext.bindtextdomain("betcon", "../lang/mo" + mainWindows.lang) gettext.bindtextdomain("betcon", "/usr/share/locale" + mainWindows.lang) self.mainWindows = mainWindows mainWindows.diconnectActions() self.mainWindows.setWindowTitle(_("Options") + " | Betcon v" + mainWindows.version) self.translate() self.btnAccept.clicked.connect(self.accept) self.btnCancel.clicked.connect(self.cancel) # TODO Al cargar el formulario debe actualiza el combobox con el valor del yml self.cmbLanguage.addItem("Deutsch", "de") self.cmbLanguage.addItem("English", "en") self.cmbLanguage.addItem("Español", "es") self.cmbLanguage.addItem("Kurdî", "ki") self.cmbLanguage.addItem("Português do Brasil", "pt_BR") self.cmbLanguage.addItem("Türk", "tr") self.config = LibYaml() self.txtPercentage.setValue(float(self.config.stake["percentage"])) self.cmbOne.setCurrentIndex(self.config.stake["type"]) self.txtStake.setValue(float(self.config.stake["stake"])) if self.config.stake["type"] == 0: self.txtStake.setEnabled(False) self.cmbOne.activated.connect(self.updateOne) self.btnCalc.clicked.connect(self.calcBank) self.txtCoin.setText(self.config.interface["coin"]) if self.config.interface['bookieCountry'] == 'Y': self.chkCountryYes.setChecked(True) else: self.chkCountryNo.setChecked(True) langIndex = {"de": 0, "en": 1, "es": 2, "ki": 3, "pt_BR": 4, "tr": 5} try: self.cmbLanguage.setCurrentIndex(langIndex[self.config.interface['lang']]) except Exception: self.cmbLanguage.setCurrentIndex(langIndex["es"]) if platform.system() == 'Linux': self.cmbLanguage.setEnabled(False) def translate(self): self.lblSetStake.setText(_("Stake")) self.lblCalculate.setText(_("Stake 1 calculation")) self.lblPercentage.setText(_("Stake 1 percentage")) self.lblStake.setText(_("Stake 1")) self.cmbOne.addItems([_("Calculated"), _("Fixed")]) self.lblInterface.setText(_("Interface")) self.lblCoin.setText(_("Coin")) self.lblCountry.setText(_("Show countries of the bookies")) self.chkCountryYes.setText(_("Yes")) self.chkCountryNo.setText(_("No")) self.btnCalc.setText(_("Calculate")) self.btnCancel.setText(_("Cancel")) self.btnAccept.setText(_("Accept")) def updateOne(self): result = self.cmbOne.currentIndex() self.txtStake.setEnabled(False) if result == 0 else self.txtStake.setEnabled(True) def calcBank(self): bd = Bbdd() bookies = Bookie.sumAll() bonus = Bookie.sumBonus() # CC cc = bd.select("bank", None, "id=1", "bank") cc = cc[0][0] # Paypal paypal = bd.select("bank", None, "id=2", "bank") paypal = paypal[0][0] # SKRILL skrill = bd.select("bank", None, "id=3", "bank") skrill = skrill[0][0] total = "{0:.2f}".format(cc + paypal + skrill + bonus + bookies) total = float(total) * (self.txtPercentage.value() * 0.01) self.txtStake.setValue(float(total)) def close(self): self.mainWindows.enableTools() self.mainWindows.setCentralWidget(Bets(self.mainWindows)) def cancel(self): self.close() def accept(self): percentage = self.txtPercentage.text()[:-1] self.config.stake["percentage"] = float(percentage) self.config.stake["type"] = self.cmbOne.currentIndex() stake = self.txtStake.text()[:-1] self.config.stake["stake"] = float(stake) self.config.interface['coin'] = self.txtCoin.text() self.config.interface['bookieCountry'] = 'Y' if self.chkCountryYes.isChecked() else 'N' self.config.interface['lang'] = self.cmbLanguage.itemData(self.cmbLanguage.currentIndex()) self.config.save() self.close()
def initData(self): # dtDate bd = Bbdd() sDate = bd.getValue(self.id, "bet", "date") date = QDateTime.fromString(sDate, "yyyy-MM-dd hh:mm:ss") self.dtDate.setDateTime(date) # cmbSport data = bd.select("sport", "name") self.sportIndexToId = {} index, idCmb = 0, 0 idBd = bd.getValue(self.id, "bet", "sport") for i in data: id = i[0] if id == idBd: idCmb = index name = i[1] self.cmbSport.addItem(name) self.sportIndexToId[index] = id index += 1 self.cmbSport.setCurrentIndex(idCmb) # cmbBookie data = bd.select("bookie", "name") index, idCmb = 0, 0 idBd = bd.getValue(self.id, "bet", "bookie") self.bookieIndexToId = {} index = 0 for i in data: id = i[0] if id == idBd: idCmb = index name = i[1] country = i[2] if LibYaml().interface['bookieCountry'] == 'Y': name += ' (' + country + ')' self.cmbBookie.addItem(name) self.bookieIndexToId[index] = id index += 1 self.cmbBookie.setCurrentIndex(idCmb) self.players = bd.executeQuery( "SELECT player1 AS player FROM bet UNION SELECT player2 AS player FROM bet ORDER BY player" ) self.players = [row[0] for row in self.players] self.txtPlayer1.addItems(self.players) self.txtPlayer2.addItems(self.players) # txtPlayer1 player1 = bd.getValue(self.id, "bet", "player1") self.txtPlayer1.setCurrentText(player1) # txtPlayer2 player2 = bd.getValue(self.id, "bet", "player2") self.txtPlayer2.setCurrentText(player2) # txtPick pick = bd.getValue(self.id, "bet", "pick") self.txtPick.setText(pick) # cmbMarket data = bd.select("market", "name") index, idCmb = 0, -1 idBd = bd.getValue(self.id, "bet", "market") self.marketIndexToId = {} index = 0 for i in data: id = i[0] if id == idBd: idCmb = index name = i[1] self.cmbMarket.addItem(name) self.marketIndexToId[index] = id index += 1 self.cmbMarket.setCurrentIndex(idCmb) # cmbTipster data = bd.select("tipster", "name") index, idCmb = 0, 0 idBd = bd.getValue(self.id, "bet", "tipster") self.tipsterIndexToId = {} index = 0 for i in data: id = i[0] if id == idBd: idCmb = index name = i[1] self.cmbTipster.addItem(name) self.tipsterIndexToId[index] = id index += 1 self.cmbTipster.setCurrentIndex(idCmb) # txtStake stake = bd.getValue(self.id, "bet", "stake") self.txtStake.setValue(stake) # txtOne one = bd.getValue(self.id, "bet", "one") self.txtOne.setValue(one) # txtBet bet = bd.getValue(self.id, "bet", "bet") self.txtBet.setValue(bet) # txtQuota quota = bd.getValue(self.id, "bet", "quota") self.txtQuota.setValue(quota) # txtProfit profit = bd.getValue(self.id, "bet", "profit") self.txtProfit.setValue(profit) result = bd.getValue(self.id, "bet", "result") self.cmbResult.setCurrentIndex(int(result)) freeBet = bd.getValue(self.id, "bet", "free") self.chkFree.setChecked(freeBet) bd.close() self.setRegion() # Combined self.contComb = 0 self.dates = [] self.sports = [] self.regions = [] self.competitions = [] self.players1 = [] self.players2 = [] self.picks = [] self.results = [] self.buttons = [] self.regionIndexToIdCmb = [] self.competitionIndexToIdCmb = []