Beispiel #1
0
 def exists(cls,iid,table):
     if table == "match":
         try:
             Match.get(iid=iid)
         except Match.DoesNotExist:
             return False
     if table == "odd":
         try:
             Odd.get(iid=iid)
         except Odd.DoesNotExist:
             return False
     if table == "cat":
         try:
             OddCategory.get(idd=iid)
         except OddCategory.DoesNotExist:
             return False
     if table == "result":
         try:
             Result.get(iid=iid)
         except Result.DoesNotExist:
             return False
     if table == "user":
         try:
             User.get(iid=iid)
         except User.DoesNotExist:
             return False
     return True
Beispiel #2
0
 def exists(cls, iid, table):
     if table == "match":
         try:
             Match.get(iid=iid)
         except Match.DoesNotExist:
             return False
     if table == "odd":
         try:
             Odd.get(iid=iid)
         except Odd.DoesNotExist:
             return False
     if table == "cat":
         try:
             OddCategory.get(idd=iid)
         except OddCategory.DoesNotExist:
             return False
     if table == "result":
         try:
             Result.get(iid=iid)
         except Result.DoesNotExist:
             return False
     if table == "user":
         try:
             User.get(iid=iid)
         except User.DoesNotExist:
             return False
     return True
Beispiel #3
0
 def check(self):
     try:
         match = Match.get(iid=self.matchCode.get_text())
         category = OddCategory.get(name=self.category.get_active_text())
         odd = Odd.get(match=match,category=category,oddCode=self.bet.get_text())
         self.addMatchButton.set_sensitive(False)
         self.reason.set_text("Match Started")
     except Match.DoesNotExist:
         self.addMatchButton.set_sensitive(False)
         self.odd.set_text("")
         self.reason.set_text("Invalid Match")
     except OddCategory.DoesNotExist:
         self.addMatchButton.set_sensitive(False)
         self.odd.set_text("")
         self.reason.set_text("Invalid Category")
     except Odd.DoesNotExist:
         self.addMatchButton.set_sensitive(False)
         self.odd.set_text("")
         self.reason.set_text("Invalid Bet")
     else:
         if match.is_valid():
             self.addMatchButton.set_sensitive(True)
             self.reason.set_text("Available")
             self.odd.set_text(str(odd.odd))
         else:
             self.addMatchButton.set_sensitive(False)
             self.reason.set_text("Match Started")
     if len(self.bets)>0 and self.amountstaked.get_text()!= "":
         self.stakebutton.set_sensitive(True)
     else:
         self.stakebutton.set_sensitive(False)
Beispiel #4
0
def check_available(match_id,oddCode,category_name):
    try:
        match = Match.get(iid=match_id)
        category = OddCategory.get(name=category_name)
        odd = Odd.get(match=match,category=category,oddCode=oddCode)
    except peewee.DoesNotExist:
        return None
    else:
        return odd.odd
Beispiel #5
0
 def syncOddTable(self):
     self.connection.request("GET", "/sync/odd")
     response = self.connection.getresponse()
     data = json.loads(response.read())
     print response.read()
     if not data.has_key('up-to-date'):
         for odd in data['name']:
             try:
                 category = OddCategory.get(iid=int(odd['category']))
                 match = Match.get(iid=int(odd['match']))
                 Odd.create(iid=odd['iid'],odd=unicode(odd['odd']), category=category, oddCode=unicode(odd['oddCode']), match=match)
             except Exception, e:
                 print str(e) + "- Odd"
Beispiel #6
0
 def syncOddTable(self):
     self.connection.request("GET", "/sync/odd")
     response = self.connection.getresponse()
     data = json.loads(response.read())
     print response.read()
     if not data.has_key('up-to-date'):
         for odd in data['name']:
             try:
                 category = OddCategory.get(iid=int(odd['category']))
                 match = Match.get(iid=int(odd['match']))
                 Odd.create(iid=odd['iid'],
                            odd=unicode(odd['odd']),
                            category=category,
                            oddCode=unicode(odd['oddCode']),
                            match=match)
             except Exception, e:
                 print str(e) + "- Odd"
Beispiel #7
0
    def on_addMatchButton_clicked(self,widget,data=None):
        matchId = self.matchCode.get_text()
        oddCode = self.bet.get_text()
        category = self.category.get_active_text()
        try:
            match = Match.get(iid=matchId)
            category = OddCategory.get(name=category)
        except peewee.DoesNotExist:
            self.addMatchButton.set_sensitive(False)
        else:

            try:
                bet = create_bet(match,oddCode,category)
                self.bets.append(bet)
                self.matchCode.set_text("")
                self.bet.set_text("")
                self.category.set_active(0)

            except BetError, e:
                #Todo Catch this error
                self.available.set_text("Unavailable")