def run(self):

        self.createSocketandListen()
        input_src = [self.serv]
        self.db = hotLaps_db.hotLapsDataBase(self.dataBaseFile)
        xmlWriter = produceReports.xmlOutput(self.db, self.outputFilenames[0], self.outputFilenames[1])
        xmlWriter.run()

        self.continueRunning = True
        print "Waiting for connections"
        while (self.continueRunning):
            try:
                inputready,outputready,exceptready = select.select(input_src,[],[],5.0)
                for s in inputready:
                    if s == self.serv:
                        conn, addr = self.serv.accept()
                        input_src.append(conn)
                    else:
                        # handle all other sockets
                        data = s.recv(1024)
                        if data:
                            # Check to make sure it is a race result
                            if self.db:
                                self.dataHandler(data)
                            xmlWriter.run()
                        else:
                            s.close()
                            input_src.remove(s)

            except Exception, err:
                print "Exception received: " + str(err)
                self.continueRunning = False
Exemple #2
0
if __name__ == '__main__':

    print "Python HotLaps test XML"

    configFile = ConfigParser.RawConfigParser()
    if len(sys.argv) >= 2:
        #read config and overwrite the conf structure
        try:
            configFile.read(sys.argv[1]) 
            conf = []
            for cfg in configFile.sections():
                row = ReadConfigFileSection(configFile, cfg)  
                conf.append(row)
        except:
            print >> sys.stderr, "Problem reading config file - exiting!"
            exit()
    else:
        print >> sys.stderr, "Need to pass the config file on the command line as an option"
        exit()
    config = conf[0]

    if not 'recordsstore' in config: 
        print >> sys.stderr, "No database file specified"        
        exit()
        
        
    db = hotLaps_db.hotLapsDataBase(config['recordsstore'])
    op = produceReports.xmlOutput(db,config['hotlapsxml'], config['uniquelapsxml'])
    
    op.run()