Esempio n. 1
0
 def race_ctrl_places_activate_cb(self, entry, data=None):
     """Respond to activate on place entry."""
     entry.set_text(strops.reformat_placelist(entry.get_text()))
     self.topn_transfer = True	# flag topn place xfer on save
     self.do_places()
     glib.idle_add(self.delayed_announce)
Esempio n. 2
0
 def race_ctrl_places_activate_cb(self, entry, data=None):
     """Respond to activate on place entry."""
     entry.set_text(strops.reformat_placelist(entry.get_text()))
     self.topn_transfer = True  # flag topn place xfer on save
     self.do_places()
     glib.idle_add(self.delayed_announce)
Esempio n. 3
0
    def loadconfig(self):
        """Load race config from disk."""
        self.riders.clear()
        # set defaults timetype based on event type
        deftimetype = 'start/finish'
        defdistance = ''
        defdistunits = 'laps'
        if self.evtype in ['sprint', 'keirin']:
            deftimetype = '200m'
            defdistunits = 'metres'
            defdistance = '200'
        cr = ConfigParser.ConfigParser({'startlist':'',
                                        'ctrl_places':'',
                                        'start':'',
                                        'lstart':'',
                                        'finish':'',
					'distance':defdistance,
					'distunits':defdistunits,
                                        'topn_places':'0',
                                        'topn_event':'',
                                        'showinfo':'Yes',
                                        'timetype':deftimetype})
        cr.add_section('race')
        cr.add_section('riders')
        if os.path.isfile(self.configpath):
            self.log.debug('Attempting to read race config from path='
                           + repr(self.configpath))
            cr.read(self.configpath)
        for r in cr.get('race', 'startlist').split():
            nr=[r, '', '', '', '', False, '']
            if cr.has_option('riders', r):
                ril = csv.reader([cr.get('riders', r)]).next()
                for i in range(0,6):
                    if len(ril) > i:
                        nr[i+1] = ril[i].strip()
                # Re-patch names if all null and in dbr
                if (nr[COL_FIRSTNAME] == ''
                     and nr[COL_LASTNAME] == ''
                     and nr[COL_CLUB] == ''):
                    dbr = self.meet.rdb.getrider(r, self.series)
                    if dbr is not None:
                        for i in range(1,4):
                            nr[i] = self.meet.rdb.getvalue(dbr, i)
            else:
                dbr = self.meet.rdb.getrider(r, self.series)
                if dbr is not None:
                    for i in range(1,4):
                        nr[i] = self.meet.rdb.getvalue(dbr, i)
            self.riders.append(nr)

        # race infos
        self.set_timetype(cr.get('race', 'timetype'))
        self.distance = strops.confopt_dist(cr.get('race', 'distance'))
        self.units = strops.confopt_distunits(cr.get('race', 'distunits'))
        self.topn_places = strops.confopt_dist(cr.get('race', 'topn_places'), 0)
        self.topn_event = cr.get('race', 'topn_event')
        self.info_expand.set_expanded(strops.confopt_bool(
                                       cr.get('race', 'showinfo')))
        self.set_start(cr.get('race', 'start'), cr.get('race', 'lstart'))
        self.set_finish(cr.get('race', 'finish'))
        self.set_elapsed()
        places = strops.reformat_placelist(cr.get('race', 'ctrl_places'))
        self.ctrl_places.set_text(places)
        self.placexfer(places)
        if places:
            self.setfinished()
Esempio n. 4
0
    def loadconfig(self):
        """Load race config from disk."""
        self.riders.clear()
        # set defaults timetype based on event type
        deftimetype = 'start/finish'
        defdistance = ''
        defdistunits = 'laps'
        if self.evtype in ['sprint', 'keirin']:
            deftimetype = '200m'
            defdistunits = 'metres'
            defdistance = '200'
        cr = ConfigParser.ConfigParser({
            'startlist': '',
            'ctrl_places': '',
            'start': '',
            'lstart': '',
            'finish': '',
            'distance': defdistance,
            'distunits': defdistunits,
            'topn_places': '0',
            'topn_event': '',
            'showinfo': 'Yes',
            'timetype': deftimetype
        })
        cr.add_section('race')
        cr.add_section('riders')
        if os.path.isfile(self.configpath):
            self.log.debug('Attempting to read race config from path=' +
                           repr(self.configpath))
            cr.read(self.configpath)
        for r in cr.get('race', 'startlist').split():
            nr = [r, '', '', '', '', False, '']
            if cr.has_option('riders', r):
                ril = csv.reader([cr.get('riders', r)]).next()
                for i in range(0, 6):
                    if len(ril) > i:
                        nr[i + 1] = ril[i].strip()
                # Re-patch names if all null and in dbr
                if (nr[COL_FIRSTNAME] == '' and nr[COL_LASTNAME] == ''
                        and nr[COL_CLUB] == ''):
                    dbr = self.meet.rdb.getrider(r, self.series)
                    if dbr is not None:
                        for i in range(1, 4):
                            nr[i] = self.meet.rdb.getvalue(dbr, i)
            else:
                dbr = self.meet.rdb.getrider(r, self.series)
                if dbr is not None:
                    for i in range(1, 4):
                        nr[i] = self.meet.rdb.getvalue(dbr, i)
            self.riders.append(nr)

        # race infos
        self.set_timetype(cr.get('race', 'timetype'))
        self.distance = strops.confopt_dist(cr.get('race', 'distance'))
        self.units = strops.confopt_distunits(cr.get('race', 'distunits'))
        self.topn_places = strops.confopt_dist(cr.get('race', 'topn_places'),
                                               0)
        self.topn_event = cr.get('race', 'topn_event')
        self.info_expand.set_expanded(
            strops.confopt_bool(cr.get('race', 'showinfo')))
        self.set_start(cr.get('race', 'start'), cr.get('race', 'lstart'))
        self.set_finish(cr.get('race', 'finish'))
        self.set_elapsed()
        places = strops.reformat_placelist(cr.get('race', 'ctrl_places'))
        self.ctrl_places.set_text(places)
        self.placexfer(places)
        if places:
            self.setfinished()