Example #1
0
    def renderJob(self, jobNo):
        """Execute the specified job number using the townguide renderer.
        """
        print "renderJob(%d)" % jobNo
        self.setJobStatus(jobNo, self.RUNNING)
        connection = psycopg.connect("dbname=%s" % self.dbname, "user=%s" % self.uname)
        mark = connection.cursor()

        sqlstr = "select jobno, renderer,xml from queue where jobno=%d;" % jobNo

        mark.execute(sqlstr)
        recordArr = mark.fetchone()
        renderer = recordArr[1]
        print "Renderer=%d" % renderer
        xmlStr = recordArr[2]
        print "xmlStr = %s" % xmlStr

        jobDir = "%s/%d" % (self.wkdir, jobNo)
        if not os.path.exists(jobDir):
            try:
                os.makedirs(jobDir)
            except:
                print "***********************************************"
                print "odd - got an error making the output directory"
                print "trying to carry on regardless!!!"
                print "***********************************************"

        xmlFile = "%s/townguide.xml" % (jobDir)
        try:
            op = open(xmlFile, "w")
            op.write(xmlStr)
            op.close()
            pr = prefs()
            pr.loadPrefs(xmlFile)
            pl = pr.getPrefs()

            pl["datadir"] = self.datadir
            pl["outdir"] = jobDir
            pl["mapfile"] = self.mapFileName

            print "mapFileName=%s." % self.mapFileName

            #            try:
            # jobLog = open("%s/townguide.log" % (jobDir))
            # queueLog = sys.stdout

            # sys.stdout = jobLog
            # sys.stderr = jobLog

            # if renderer==1:
            #    tg = townguide.townguide(pr)
            # else:
            #    tg = townguide2.townguide(pr)
            tg = townguide.townguide(pr)
            self.setJobStatus(jobNo, self.COMPLETE)
            sys.stdout.flush()
            # sys.stdout = queueLog
            # sys.stderr = queueLog
            # except:
            #    print "Oh No - error opening log file, or townguide failed"
            #    self.setJobStatus(jobNo,self.ERROR)
        except Exception, e:
            print "Oh No - Error processing job number %d" % jobNo
            print "Unexpected error:", sys.exc_info()[0]
            print "%s" % (dir(e))
            print sys.exc_info()
            self.setJobStatus(jobNo, self.ERROR)
Example #2
0
        verbose = False)
    (options,args)=parser.parse_args()
    
    if (options.debug):
        options.verbose = True
        print "options   = %s" % options
        print "arguments = %s" % args


    # print
    # print "Townguide Version %s" % version
    # print
    
    if len(args)==0:
        print "No configuration file specified - using a simple default configuration as an example."
        preferences_list = {'title':'townguide default output',
              'origin':'54.6466,-1.2619',
              'mapsize':'10,12',
              'tilesize':'1000',
              'features':'amenity=school,amenity=pub'}
    else:
        print "Using configuration file %s." % args[0]
        preferences = prefs()
        preferences_list = preferences.loadPrefs(args[0])

    # tg = townguide(54.6466,-1.2619,1000,10,12)
    # townguide_map = townguide(preferences)
    # townguide(preferences)
    townguide.townguide(preferences)