Example #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
Example #2
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"
Example #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)
Example #4
0
 def syncResult(self):
     self.connection.request("GET", "/sync/result")
     response = self.connection.getresponse()
     data = json.loads(response.read())
     print response.read()
     if not data.has_key('up-to-date'):
         for result in data['name']:
             odd = Odd.get(iid=result['odd'])
             Result.create(iid=result['iid'],odd=odd)
Example #5
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
Example #6
0
 def __init__(self):
     OddCategory.create_table(fail_silently=True)
     Match.create_table(fail_silently=True)
     Ticket.create_table(fail_silently=True)
     Odd.create_table(fail_silently=True)
     Result.create_table(fail_silently=True)
Example #7
0
def get_side_picked(match_id,side):
    match = check_available(match_id)
    if match:
        odd = Odd.get(match=match,oddCode=side)
        return odd.odd
Example #8
0
def create_bet(match,oddCode,category):
    try:
        odd = Odd.get(match=match,category=category,oddCode=oddCode)
    except peewee.DoesNotExist, e:
        raise BetError(str(e))