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
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
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)
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)
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
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)
def get_side_picked(match_id,side): match = check_available(match_id) if match: odd = Odd.get(match=match,oddCode=side) return odd.odd
def create_bet(match,oddCode,category): try: odd = Odd.get(match=match,category=category,oddCode=oddCode) except peewee.DoesNotExist, e: raise BetError(str(e))