Example #1
0
    def loadconfig(self):
        """Load race config from disk."""
        self.riders.clear()
        cr = ConfigParser.ConfigParser({
            'startlist': '',
            'showinfo': 'Yes',
            'events': '',
            'evnicks': ''
        })
        cr.add_section('race')
        cr.add_section('riders')  # no need fr omnium??

        if os.path.isfile(self.configpath):
            self.log.debug('Attempting to read config from ' +
                           repr(self.configpath))
            cr.read(self.configpath)
        for r in cr.get('race', 'startlist').split():
            self.addrider(r)
            ## TODO : load/save comment for rider

        self.info_expand.set_expanded(
            strops.confopt_bool(cr.get('race', 'showinfo')))

        self.events = strops.reformat_bibserlist(cr.get('race', 'events'))
        self.nicknames = cr.get('race', 'evnicks').split()
        self.recalculate()
Example #2
0
    def loadconfig(self):
        """Load config from disk."""
        cr = ConfigParser.ConfigParser({
            'host': USCBSRV_HOST,
            'port': str(USCBSRV_PORT),
            'channel': USCBSRV_CHANNEL,
            'srvnick': USCBSRV_SRVNICK,
            'cltnick': USCBSRV_CLTNICK,
            'fontsize': str(FONTSIZE),
            'fullscreen': 'Yes',
            'motd': MOTD
        })
        cr.add_section('uscbsrv')
        cr.add_section('announce')
        # check for config file
        try:
            a = len(cr.read(CONFIGFILE))
            if a == 0:
                print('No config file found - loading default values.')
        except Exception as e:
            print('Error reading config: ' + str(e))

        self.motd = cr.get('announce', 'motd')
        if strops.confopt_bool(cr.get('announce', 'fullscreen')):
            self.window.fullscreen()

        nhost = cr.get('uscbsrv', 'host')
        nport = strops.confopt_posint(cr.get('uscbsrv', 'port'), USCBSRV_PORT)
        nchannel = cr.get('uscbsrv', 'channel')
        ncltnick = cr.get('uscbsrv', 'cltnick')
        nsrvnick = cr.get('uscbsrv', 'srvnick')
        self.io.set_port(nhost, nport, nchannel, ncltnick, nsrvnick)
Example #3
0
    def loadconfig(self):
        """Load race config from disk."""
        self.riders.clear()
        #self.results.clear()

        # defaults
        # +type specific overrides
        cr = ConfigParser.ConfigParser({
            'startlist': '',
            'start': '',
            'lstart': '',
            'places': '',
            'limit': ''
        })
        cr.add_section('race')
        cr.add_section('riders')
        if os.path.isfile(self.configpath):
            self.log.debug('Attempting to read config from ' +
                           repr(self.configpath))
            cr.read(self.configpath)

        # re-load starters/results
        for rs in cr.get('race', 'startlist').split():
            (r, s) = strops.bibstr2bibser(rs)
            self.addrider(r, s)
            if cr.has_option('riders', rs):
                # bbb.sss = comment,inrace,hcap,finish,mbunch
                nr = self.getrider(r, s)
                ril = csv.reader([cr.get('riders', rs)]).next()
                lr = len(ril)
                if lr > 0:
                    nr[COL_COMMENT] = ril[0]
                if lr > 1:
                    nr[COL_INRACE] = strops.confopt_bool(ril[1])
                if lr > 2:
                    nr[COL_HCAP] = tod.str2tod(ril[2])
                if lr > 3:
                    nr[COL_FINISH] = tod.str2tod(ril[3])
                if lr > 4:
                    nr[COL_MBUNCH] = tod.str2tod(ril[4])
                if nr[COL_HCAP] is None:
                    nr[COL_HCAP] = tod.ZERO  # default to 'scratch'
                if self.limit_tod is not None:
                    if nr[COL_HCAP] > self.limit_tod:
                        self.log.error('Handicap greater than limit for ' +
                                       rs + ' set to limit.')
                        nr[COL_HCAP] = self.limit_tod

        places = strops.reformat_bibserplacelist(cr.get('race', 'places'))
        #!!!
        #self.ctrl_places.set_text(places)
        #self.ctrl_places.set_sensitive(False)
        #self.recalculate()

        # re-join an existing timer state
        self.set_start(tod.str2tod(cr.get('race', 'start')),
                       tod.str2tod(cr.get('race', 'lstart')))
Example #4
0
    def loadconfig(self):
        """Load race config from disk."""
        self.riders.clear()
        #self.results.clear()

        # defaults
        # +type specific overrides
        cr = ConfigParser.ConfigParser({'startlist':'',
					'start':'',
                                        'lstart':'',
                                        'places':'',
                                        'limit':''
                                       })
        cr.add_section('race')
        cr.add_section('riders')
        if os.path.isfile(self.configpath):
            self.log.debug('Attempting to read config from '
                               + repr(self.configpath))
            cr.read(self.configpath)

        # re-load starters/results
        for rs in cr.get('race', 'startlist').split():
            (r, s) = strops.bibstr2bibser(rs)
            self.addrider(r, s)
            if cr.has_option('riders', rs):
                # bbb.sss = comment,inrace,hcap,finish,mbunch
                nr = self.getrider(r, s)
                ril = csv.reader([cr.get('riders', rs)]).next()
                lr = len(ril)
                if lr > 0:
                    nr[COL_COMMENT] = ril[0]
                if lr > 1:
                    nr[COL_INRACE] = strops.confopt_bool(ril[1])
                if lr > 2:
                    nr[COL_HCAP] = tod.str2tod(ril[2])
                if lr > 3:
                    nr[COL_FINISH] = tod.str2tod(ril[3])
                if lr > 4:
                    nr[COL_MBUNCH] = tod.str2tod(ril[4])
                if nr[COL_HCAP] is None:
                    nr[COL_HCAP] = tod.ZERO		# default to 'scratch'
                if self.limit_tod is not None:
                    if nr[COL_HCAP] > self.limit_tod:
                        self.log.error('Handicap greater than limit for '
                                        + rs + ' set to limit.')
                        nr[COL_HCAP] = self.limit_tod

        places = strops.reformat_bibserplacelist(cr.get('race', 'places'))
#!!!
        #self.ctrl_places.set_text(places)
        #self.ctrl_places.set_sensitive(False)
        #self.recalculate()

        # re-join an existing timer state
        self.set_start(tod.str2tod(cr.get('race', 'start')),
                       tod.str2tod(cr.get('race', 'lstart')))
Example #5
0
    def loadconfig(self):
        """Load config from disk."""
        cr = ConfigParser.ConfigParser(
            {
                "host": USCBSRV_HOST,
                "port": str(USCBSRV_PORT),
                "channel": USCBSRV_CHANNEL,
                "srvnick": USCBSRV_SRVNICK,
                "cltnick": USCBSRV_CLTNICK,
                "timetick": str(TIMETICK),
                "fontsize": str(FONTSIZE),
                "fullscreen": "Yes",
                "motd": MOTD,
            }
        )
        cr.add_section("uscbsrv")
        cr.add_section("announce")
        # check for config file
        try:
            a = len(cr.read(CONFIGFILE))
            if a == 0:
                print("No config file found - loading default values.")
        except e:
            print("Error reading config: " + str(e))

        self.timetick = strops.confopt_posint(cr.get("announce", "timetick"), TIMETICK)
        self.fontsize = strops.confopt_posint(cr.get("announce", "fontsize"), FONTSIZE)
        self.motd = cr.get("announce", "motd")
        if strops.confopt_bool(cr.get("announce", "fullscreen")):
            self.window.fullscreen()

        nhost = cr.get("uscbsrv", "host")
        nport = strops.confopt_posint(cr.get("uscbsrv", "port"), USCBSRV_PORT)
        nchannel = cr.get("uscbsrv", "channel")
        ncltnick = cr.get("uscbsrv", "cltnick")
        nsrvnick = cr.get("uscbsrv", "srvnick")
        self.io.set_port(nhost, nport, nchannel, ncltnick, nsrvnick)

        fnszstr = str(self.fontsize) + "px"
        self.lbl_header.modify_font(pango.FontDescription("bold " + fnszstr))
        self.elap_lbl.modify_font(pango.FontDescription("monospace bold " + fnszstr))
        self.search_lbl.modify_font(pango.FontDescription(fnszstr))
        self.search_entry.modify_font(pango.FontDescription(fnszstr))
        self.view.modify_font(pango.FontDescription("bold " + fnszstr))
Example #6
0
    def loadconfig(self):
        """Load config from disk."""
        cr = ConfigParser.ConfigParser({'host':USCBSRV_HOST,
                                        'port':str(USCBSRV_PORT),
                                        'channel':USCBSRV_CHANNEL,
                                        'srvnick':USCBSRV_SRVNICK,
                                        'cltnick':USCBSRV_CLTNICK,
                                        'timetick':str(TIMETICK),
                                        'fontsize':str(FONTSIZE),
                                        'fullscreen':'Yes',
                                        'motd':MOTD})
        cr.add_section('uscbsrv')
        cr.add_section('announce')
        # check for config file
        try:
            a = len(cr.read(CONFIGFILE))
            if a == 0:
                print('No config file found - loading default values.')
        except e:
            print('Error reading config: ' + str(e))

        self.timetick = strops.confopt_posint(cr.get('announce', 'timetick'),
                                              TIMETICK)
        self.fontsize = strops.confopt_posint(cr.get('announce', 'fontsize'),
                                              FONTSIZE)
        self.motd = cr.get('announce', 'motd')
        if strops.confopt_bool(cr.get('announce', 'fullscreen')):
            self.window.fullscreen()

        nhost = cr.get('uscbsrv', 'host')
        nport = strops.confopt_posint(cr.get('uscbsrv', 'port'),
                                      USCBSRV_PORT)
        nchannel = cr.get('uscbsrv', 'channel')
        ncltnick =cr.get('uscbsrv', 'cltnick')
        nsrvnick = cr.get('uscbsrv', 'srvnick')
        self.io.set_port(nhost, nport, nchannel, ncltnick, nsrvnick)

        fnszstr = str(self.fontsize)+'px'
        self.lbl_header.modify_font(pango.FontDescription('bold '+fnszstr))
        self.elap_lbl.modify_font(pango.FontDescription('monospace bold '+fnszstr))
        self.search_lbl.modify_font(pango.FontDescription(fnszstr))
        self.search_entry.modify_font(pango.FontDescription(fnszstr))
        self.view.modify_font(pango.FontDescription('bold '+fnszstr))
Example #7
0
    def loadconfig(self):
        """Load race config from disk."""
        self.riders.clear()
        cr = ConfigParser.ConfigParser({'startlist':'',
                                        'showinfo':'Yes',
                                        'events':'',
                                        'evnicks':''})
        cr.add_section('race')
        cr.add_section('riders') # no need fr omnium??

        if os.path.isfile(self.configpath):
            self.log.debug('Attempting to read config from '
                               + repr(self.configpath))
            cr.read(self.configpath)
        for r in cr.get('race', 'startlist').split():
            self.addrider(r)
            ## TODO : load/save comment for rider

        self.info_expand.set_expanded(strops.confopt_bool(
                                       cr.get('race', 'showinfo')))

        self.events = strops.reformat_bibserlist(cr.get('race', 'events'))
        self.nicknames = cr.get('race', 'evnicks').split()
        self.recalculate()
Example #8
0
    def loadconfig(self):

        #!! FIX !! -> loading distance
        #-> loading/saving uscbsrv port
        #-> defaults for uscbsrv
        #-> default timy port should be ''
        """Load meet config from disk."""
        cr = ConfigParser.ConfigParser({
            'maintimer': '',
            'rfunit': wheeltime.WHEELIP,
            'resultcats': 'No',
            'resultbibs': 'Yes',
            'distance': '1.0',
            'docindex': '0',
            'line1': '',
            'line2': '',
            'line3': '',
            'uscbsrv': '',
            'uscbchan': '#announce',
            'uscbopt': 'No',
            'logos': ''
        })
        cr.add_section('meet')
        cwfilename = os.path.join(self.configpath, 'config')

        # re-set main log file
        if self.loghandler is not None:
            self.log.removeHandler(self.loghandler)
            self.loghandler.close()
            self.loghandler = None
        self.loghandler = logging.FileHandler(
            os.path.join(self.configpath, 'log'))
        self.loghandler.setLevel(LOGHANDLER_LEVEL)
        self.loghandler.setFormatter(
            logging.Formatter(
                '%(asctime)s %(levelname)s:%(name)s: %(message)s'))
        self.log.addHandler(self.loghandler)

        # setup scratchpad? for later thought with load/save/prev/next
        self.find_next_scratchfile()
        self.log.info('Initialised scratchpad #' + str(self.scratch_idx))

        # check for config file
        try:
            a = len(cr.read(cwfilename))
            if a == 0:
                self.log.warn('No config file - loading default values.')
        except e:
            self.log.error('Error reading meet config: ' + str(e))

        # set timer port
        nport = cr.get('meet', 'maintimer')
        if nport != self.timer_port:
            self.timer_port = nport
            self.timer.setport(nport)
            self.timer.sane()

        # set rfunit addr
        nport = cr.get('meet', 'rfunit')
        if nport != self.rfu_addr:
            self.rfu_addr = nport
            self.rfu.setaddr(nport)

        # set meet meta infos, and then copy into text entries
        self.line1 = cr.get('meet', 'line1')
        self.line2 = cr.get('meet', 'line2')
        self.line3 = cr.get('meet', 'line3')
        self.logos = cr.get('meet', 'logos')
        self.set_title()

        # result options
        self.bibs_in_results = strops.confopt_bool(cr.get(
            'meet', 'resultbibs'))
        self.cats_in_results = strops.confopt_bool(cr.get(
            'meet', 'resultcats'))

        # race length
        self.distance = strops.confopt_dist(cr.get('meet', 'distance'), 20)

        # document id
        self.docindex = strops.confopt_dist(cr.get('meet', 'docindex'), 0)

        self.rdb.clear()
        self.edb.clear()
        self.rdb.load(os.path.join(self.configpath, 'riders.csv'))
        self.edb.load(os.path.join(self.configpath, 'events.csv'))
        event = self.edb.getevent()
        if event is None:  # add a new event to the model
            event = self.edb.editevent(num='00', etype=self.etype)
        self.open_event(event)  # always open on load if posible

        # restore printer preferences
        psfilename = os.path.join(self.configpath, 'print.prf')
        if os.path.isfile(psfilename):
            try:
                self.printprefs.load_file(psfilename)
            except:
                self.log.warn('Error loading print preferences.')
Example #9
0
    def loadconfig(self):
        """Load meet config from disk."""
        cr = ConfigParser.ConfigParser(
            {
                "maintimer": timy.MAINPORT,
                "rfunit": wheeltime.WHEELIP,
                "resultcats": "No",
                "resultbibs": "Yes",
                "distance": "20",
                "line1": "",
                "line2": "",
                "line3": "",
                "logos": "",
            }
        )
        cr.add_section("meet")
        cwfilename = os.path.join(self.configpath, "config")

        # re-set main log file
        if self.loghandler is not None:
            self.log.removeHandler(self.loghandler)
            self.loghandler.close()
            self.loghandler = None
        self.loghandler = logging.FileHandler(os.path.join(self.configpath, "log"))
        self.loghandler.setLevel(LOGHANDLER_LEVEL)
        self.loghandler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s:%(name)s: %(message)s"))
        self.log.addHandler(self.loghandler)

        # check for config file
        try:
            a = len(cr.read(cwfilename))
            if a == 0:
                self.log.warn("No config file found - loading default values.")
        except e:
            self.log.error("Error reading meet config: " + str(e))

        # set timer port
        nport = cr.get("meet", "maintimer")
        if nport != self.timer_port:
            self.timer_port = nport
            self.timer.setport(nport)
            self.timer.sane()

        # set rfunit addr
        nport = cr.get("meet", "rfunit")
        if nport != self.rfu_addr:
            self.rfu_addr = nport
            self.rfu.setaddr(nport)

        # set meet meta infos, and then copy into text entries
        self.line1 = cr.get("meet", "line1")
        self.line2 = cr.get("meet", "line2")
        self.line3 = cr.get("meet", "line3")
        self.logos = cr.get("meet", "logos")
        self.set_title()

        # result options
        self.bibs_in_results = strops.confopt_bool(cr.get("meet", "resultbibs"))
        self.cats_in_results = strops.confopt_bool(cr.get("meet", "resultcats"))

        # race length
        self.distance = strops.confopt_dist(cr.get("meet", "distance"), 20)

        self.rdb.clear()
        self.edb.clear()
        self.rdb.load(os.path.join(self.configpath, "riders.csv"))
        self.edb.load(os.path.join(self.configpath, "events.csv"))
        tt_event = self.edb.getevent("tt")
        if tt_event is None:  # add a new event to the model
            tt_event = self.edb.editevent(num="tt", etype="irtt")
        self.open_event(tt_event)  # always open on load if possible
Example #10
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()
Example #11
0
    def loadconfig(self):

#!! FIX !! -> loading distance
	  #-> loading/saving uscbsrv port
	  #-> defaults for uscbsrv
	  #-> default timy port should be ''

        """Load meet config from disk."""
        cr = ConfigParser.ConfigParser({'maintimer':'',
                                        'rfunit':wheeltime.WHEELIP,
                                        'resultcats':'No',
					'resultbibs':'Yes',
                                        'distance':'1.0',
                                        'docindex':'0',
                                        'line1':'',
                                        'line2':'',
                                        'line3':'',
                                        'uscbsrv':'',
                                        'uscbchan':'#announce',
                                        'uscbopt':'No',
                                        'logos':''})
        cr.add_section('meet')
        cwfilename = os.path.join(self.configpath, 'config')

        # re-set main log file
        if self.loghandler is not None:
            self.log.removeHandler(self.loghandler)
            self.loghandler.close()
            self.loghandler = None
        self.loghandler = logging.FileHandler(
                             os.path.join(self.configpath, 'log'))
        self.loghandler.setLevel(LOGHANDLER_LEVEL)
        self.loghandler.setFormatter(logging.Formatter(
                       '%(asctime)s %(levelname)s:%(name)s: %(message)s'))
        self.log.addHandler(self.loghandler)

        # setup scratchpad? for later thought with load/save/prev/next
        self.find_next_scratchfile()
        self.log.info('Initialised scratchpad #' + str(self.scratch_idx))

        # check for config file
        try:
            a = len(cr.read(cwfilename))
            if a == 0:
                self.log.warn('No config file - loading default values.')
        except e:
            self.log.error('Error reading meet config: ' + str(e))

        # set timer port
        nport = cr.get('meet', 'maintimer')
        if nport != self.timer_port:
            self.timer_port = nport
            self.timer.setport(nport)
            self.timer.sane()

        # set rfunit addr
        nport = cr.get('meet', 'rfunit')
        if nport != self.rfu_addr:
            self.rfu_addr = nport
            self.rfu.setaddr(nport)

        # set meet meta infos, and then copy into text entries
        self.line1 = cr.get('meet', 'line1')
        self.line2 = cr.get('meet', 'line2')
        self.line3 = cr.get('meet', 'line3')
        self.logos = cr.get('meet', 'logos')
        self.set_title()

        # result options
        self.bibs_in_results = strops.confopt_bool(
                                        cr.get('meet', 'resultbibs'))
        self.cats_in_results = strops.confopt_bool(
                                        cr.get('meet', 'resultcats'))

        # race length
        self.distance = strops.confopt_dist(cr.get('meet', 'distance'), 20)

        # document id
        self.docindex = strops.confopt_dist(cr.get('meet', 'docindex'), 0)

        self.rdb.clear()
        self.edb.clear()
        self.rdb.load(os.path.join(self.configpath, 'riders.csv'))
        self.edb.load(os.path.join(self.configpath, 'events.csv'))
        event = self.edb.getevent()
        if event is None:	# add a new event to the model
            event = self.edb.editevent(num='00', etype=self.etype)
        self.open_event(event) # always open on load if posible

        # restore printer preferences
        psfilename = os.path.join(self.configpath, 'print.prf')
        if os.path.isfile(psfilename):
            try:
                self.printprefs.load_file(psfilename)
            except:
                self.log.warn('Error loading print preferences.')
Example #12
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()
Example #13
0
    def loadconfig(self):
        """Load meet config from disk."""
        cr = ConfigParser.ConfigParser({
            'maintimer': timy.MAINPORT,
            'rfunit': wheeltime.WHEELIP,
            'resultcats': 'No',
            'resultbibs': 'Yes',
            'distance': '20',
            'line1': '',
            'line2': '',
            'line3': '',
            'logos': ''
        })
        cr.add_section('meet')
        cwfilename = os.path.join(self.configpath, 'config')

        # re-set main log file
        if self.loghandler is not None:
            self.log.removeHandler(self.loghandler)
            self.loghandler.close()
            self.loghandler = None
        self.loghandler = logging.FileHandler(
            os.path.join(self.configpath, 'log'))
        self.loghandler.setLevel(LOGHANDLER_LEVEL)
        self.loghandler.setFormatter(
            logging.Formatter(
                '%(asctime)s %(levelname)s:%(name)s: %(message)s'))
        self.log.addHandler(self.loghandler)

        # check for config file
        try:
            a = len(cr.read(cwfilename))
            if a == 0:
                self.log.warn('No config file found - loading default values.')
        except e:
            self.log.error('Error reading meet config: ' + str(e))

        # set timer port
        nport = cr.get('meet', 'maintimer')
        if nport != self.timer_port:
            self.timer_port = nport
            self.timer.setport(nport)
            self.timer.sane()

        # set rfunit addr
        nport = cr.get('meet', 'rfunit')
        if nport != self.rfu_addr:
            self.rfu_addr = nport
            self.rfu.setaddr(nport)

        # set meet meta infos, and then copy into text entries
        self.line1 = cr.get('meet', 'line1')
        self.line2 = cr.get('meet', 'line2')
        self.line3 = cr.get('meet', 'line3')
        self.logos = cr.get('meet', 'logos')
        self.set_title()

        # result options
        self.bibs_in_results = strops.confopt_bool(cr.get(
            'meet', 'resultbibs'))
        self.cats_in_results = strops.confopt_bool(cr.get(
            'meet', 'resultcats'))

        # race length
        self.distance = strops.confopt_dist(cr.get('meet', 'distance'), 20)

        self.rdb.clear()
        self.edb.clear()
        self.rdb.load(os.path.join(self.configpath, 'riders.csv'))
        self.edb.load(os.path.join(self.configpath, 'events.csv'))
        tt_event = self.edb.getevent('tt')
        if tt_event is None:  # add a new event to the model
            tt_event = self.edb.editevent(num='tt', etype='irtt')
        self.open_event(tt_event)  # always open on load if possible