コード例 #1
0
ファイル: sync.py プロジェクト: Okiria/betting
 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
コード例 #2
0
ファイル: sync.py プロジェクト: Okiria/betting
 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
コード例 #3
0
ファイル: sync.py プロジェクト: Okiria/betting
 def syncOddCatTable(self):
     self.connection.request("GET", "/sync/oddcat")
     response = self.connection.getresponse()
     data = response.read()
     data = json.loads(data)
     print response.read()
     if not data.has_key('up-to-date'):
         for cat in data['name']:
             try:
                 OddCategory.create(iid=cat['iid'],name=cat['name'])
             except Exception, e:
                 print str(e) + "- OddCat"
コード例 #4
0
ファイル: sync.py プロジェクト: Okiria/betting
 def syncOddCatTable(self):
     self.connection.request("GET", "/sync/oddcat")
     response = self.connection.getresponse()
     data = response.read()
     data = json.loads(data)
     print response.read()
     if not data.has_key('up-to-date'):
         for cat in data['name']:
             try:
                 OddCategory.create(iid=cat['iid'], name=cat['name'])
             except Exception, e:
                 print str(e) + "- OddCat"
コード例 #5
0
ファイル: bet_interface.py プロジェクト: Okiria/betting
 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)
コード例 #6
0
ファイル: api.py プロジェクト: Okiria/betting
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
コード例 #7
0
ファイル: sync.py プロジェクト: Okiria/betting
 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"
コード例 #8
0
ファイル: sync.py プロジェクト: Okiria/betting
 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"
コード例 #9
0
ファイル: bet_interface.py プロジェクト: Okiria/betting
    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")
コード例 #10
0
ファイル: bet_interface.py プロジェクト: Okiria/betting
    def __init__(self):
        builder = gtk.Builder()
        builder.add_from_file("interface.glade")
        self.window = builder.get_object("window")
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.set_size_request(1000,600)
        builder.connect_signals(self)



        self.reason = builder.get_object("reason")
        self.confirmVbox = builder.get_object("confirmVbox")
        self.bet_box = builder.get_object("bet_box")
        self.enterbet_box = builder.get_object("enterbet_box")
        self.confirmButton = builder.get_object("confirmButton")
        self.addNotify = builder.get_object("addNotify")
        self.current_user = builder.get_object("current_user")
        self.username_box = builder.get_object("username_box")
        self.password_box = builder.get_object("password_box")
        self.loginbutton_box = builder.get_object("loginbutton_box")
        self.loginbox = builder.get_object("loginbox")
        self.currentusers_box = builder.get_object("currentusers_box")
        self.anothermatch_label = builder.get_object("anothermatch_label")
        self.stakebox = builder.get_object("stakebox")
        self.payment_box = builder.get_object("payment_box")
        self.back = builder.get_object("back")
        self.verifyreciept_box = builder.get_object("verifyreciept_box")
        self.done_verifying = builder.get_object("done_verifying")
        self.cancel_match = builder.get_object("cancel_match")
        self.user_now = builder.get_object("user_now")
        self.username_text = builder.get_object("username_text")
        self.password_text = builder.get_object("password_text")
        self.totalstake = builder.get_object("totalstake")
        self.amountstaked = builder.get_object("amountstaked")
        self.amount = builder.get_object("amount")
        self.matchCode = builder.get_object("matchCode")
        self.bet = builder.get_object("bet")
        self.validity_label = builder.get_object("validity_label")
        self.serial_number = builder.get_object("serial_number")
        self.totalOdd = builder.get_object("totalOdd")
        self.exAmount = builder.get_object("exAmount")
        self.wrong_login = builder.get_object("wrong_login")
        self.aligning = builder.get_object("aligning")
        self.addanothermatch_label = builder.get_object("addanothermatch_label")
        self.odd = builder.get_object('odd')
        self.available = builder.get_object('available')
        self.stakebutton = builder.get_object('stakeButton')
        self.login = builder.get_object('login')
        self.addMatchButton = builder.get_object('addMatchButton')
        self.category = builder.get_object("category_combo")
        self.hbox2 = builder.get_object("hbox2")
        self.verify_serial = builder.get_object("verify_serial")
        self.done_paying = builder.get_object("done_paying")
        self.pay = builder.get_object("pay")
        self.connection = builder.get_object("connection")
        self.noPrinter = builder.get_object("no_printer")
        self.update = builder.get_object("update")
        self.connect_printer = builder.get_object("printer_connection")

        self.store = gtk.ListStore(gobject.TYPE_STRING)

        self.addMatchButton.set_sensitive(False)
        self.verify_serial.set_sensitive(False)
        self.validity_label.set_text("Invalid")


        cats = [[cat.name] for cat in OddCategory.select()]

        for c in cats:
            self.store.append(c)
        self.category.set_model(model=self.store)
        cell = gtk.CellRendererText()
        self.category.pack_start(cell,True)
        self.category.add_attribute(cell,'text',0)
        self.category.set_active(0)

        if self.amountstaked.get_text()=="":
            self.stakebutton.set_sensitive(False)

        self.odd.set_text("")
        self.confirmVbox.hide()
        self.currentusers_box.hide()
        self.anothermatch_label.hide()
        self.enterbet_box.hide()
        self.stakebox.hide()
        self.bet_box.hide()
        self.payment_box.hide()
        self.verifyreciept_box.hide()
        self.amount.hide()
        self.amountstaked.hide()
コード例 #11
0
ファイル: sync.py プロジェクト: Okiria/betting
 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)
コード例 #12
0
ファイル: sync.py プロジェクト: Okiria/betting
 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)