예제 #1
0
def make_compare_entry(dbname,ifile, device, dpi, band):

    ofile = "%s.%s.%d.%d" % (ifile, device, dpi, band)
    print "creating entry: " + ofile + "...",
    sys.stdout.flush()
    
    gs = gstestgs.Ghostscript()

    gs.gsroot = gsconf.gsroot
    gs.log_stdout = gsconf.gs_stdout
    gs.log_stderr = gsconf.gs_stderr
    gs.command = gsconf.headinstallpath

    gs.infile = gsconf.comparefiledir + ifile
    gs.outfile = ofile
    gs.device = device
    gs.dpi = dpi
    gs.band = band

    if not gssum.exists(ofile,dbname):
        if gs.process():
	    try:
       	        gssum.add_file(ofile,dbname)
                rasterdb.put_file(ofile)
    	        os.unlink(ofile)
    	        print "done."
            except OSError:
                print "no output produced."
        else:
	    print "error."
    else:
	print "exists."
예제 #2
0
def make_compare_entry(ifile, device, dpi, band):
    ofile = "%s.%s.%d.%d" % (ifile, device, dpi, band)
    print "creating entry: " + ofile + "...",
    sys.stdout.flush()
    
    gs = gstestgs.Ghostscript()
    gs.log_stdout = gsconf.log_stdout
    gs.log_stderr = gsconf.log_stderr
    gs.command = gsconf.baselinegs
    gs.infile = gsconf.comparefiledir + ifile
    gs.outfile = ofile
    gs.device = device
    gs.dpi = dpi
    gs.band = band

    if not gssum.exists(ofile):
        if gs.process():
	    try:
       	        gssum.add_file(ofile)
                rasterdb.put_file(ofile)
    	        os.unlink(ofile)
    	        print "done."
            except OSError:
                print "no output produced."
        else:
	    print "error."
    else:
	print "exists."
def update_databases(outputfile, device, dpi, band, revision, options):

    log = open(gsconf.baseline_log, "a")

    outputdevice = " ".join((device, str(dpi), str(band)))
    message = time.ctime(
    ) + " " + testfile + " " + outputdevice + " updated " + revision

    if options and options.dryrun:
        print "dryrun", message
    else:
        log.write(message + "\n")
        log.close()

    baselinedb = gsconf.baselinedb
    if options and options.dryrun:
        pass
    else:
        gssum.add_file(outputfile, baselinedb)

    if options and options.dryrun:
        pass
    else:
        rasterdb.put_file(outputfile)

    if not options.nocleanup:
        os.unlink(outputfile)
def update_databases(outputfile,device,dpi,band,revision,options):

    log = open(gsconf.baseline_log, "a")

    outputdevice=" ".join((device,str(dpi),str(band)))
    message=time.ctime() + " " + testfile +" "+outputdevice+ " updated "+revision

    if options and options.dryrun:
        print "dryrun",message
    else:
        log.write(message+"\n")
        log.close()

    baselinedb=gsconf.baselinedb
    if options and options.dryrun:
        pass
    else:
        gssum.add_file(outputfile,baselinedb)

    if options and options.dryrun:
        pass
    else:
        rasterdb.put_file(outputfile)

    if not options.nocleanup:
        os.unlink(outputfile)
    def runTest(self):
        if hasattr(self, "skip") and self.skip == 1:
            self.assert_(True)
            return

        outputfile = "%s.%s.%d.%d" % (self.file[string.rindex(self.file, '/') +
                                                1:], self.device, self.dpi,
                                      self.band)

        gs = gstestgs.Ghostscript()

        gs.gsroot = self.gsroot
        gs.device = self.device
        gs.dpi = self.dpi
        gs.band = self.band
        gs.infile = self.file
        gs.outfile = outputfile
        if self.log_stdout:
            gs.log_stdout = self.log_stdout
        if self.log_stderr:
            gs.log_stderr = self.log_stderr

        if gs.process():
            sum = gssum.make_sum(outputfile)
        else:
            sum = ''

        if os.path.exists(outputfile):
            shutil.move(outputfile, gsconf.datadir + "/raster.daily")
#           os.unlink(outputfile)

        if sum and self.track_daily:  # add test result to daily database
            if gsconf.__dict__.has_key("checksumdb") and gsconf.checksumdb:
                dbname = gsconf.dailydir + gsconf.checksumdb  # mhw +".db"
            else:
                dbname = gsconf.get_dailydb_name()
            gssum.add_file(outputfile, dbname=dbname, sum=sum)

        if not sum:
            message = myself + " output file " + outputfile + " was not created for input file: " + self.file
            self.fail(message)
        else:
            if gssum.exists(outputfile, gsconf.baselinedb):
                sum_baseline = gssum.get_sum(outputfile, gsconf.baselinedb)
                message = myself + ' checksum did not match baseline (' + outputfile + ') for input file: ' + self.file
                self.assertEqual(sum, sum_baseline, message)
            else:
                message = myself + " no baseline checksum (" + outputfile + ") for file: " + self.file
                self.fail(message)
    def runTest(self):
        if hasattr(self, "skip") and self.skip == 1:
	    self.assert_(True)
	    return

	outputfile = "%s.%s.%d.%d" % (self.file[string.rindex(self.file, '/') + 1:], self.device, self.dpi, self.band)

	gs = gstestgs.Ghostscript()

	gs.gsroot = self.gsroot
	gs.device = self.device
	gs.dpi = self.dpi
	gs.band = self.band
	gs.infile = self.file
	gs.outfile = outputfile
	if self.log_stdout:
	    gs.log_stdout = self.log_stdout
	if self.log_stderr:
	    gs.log_stderr = self.log_stderr

	if gs.process():
	    sum = gssum.make_sum(outputfile)
        else:
	    sum = ''

        if os.path.exists(outputfile):
            shutil.move(outputfile, gsconf.datadir+"/raster.daily")
#           os.unlink(outputfile)

	if sum and self.track_daily:	                                                  # add test result to daily database
            if gsconf.__dict__.has_key("checksumdb") and gsconf.checksumdb:
                dbname=gsconf.dailydir+gsconf.checksumdb # mhw +".db"
            else:
                dbname=gsconf.get_dailydb_name()
            gssum.add_file(outputfile, dbname=dbname, sum=sum)

	if not sum:
	    message=myself+" output file "+outputfile+" was not created for input file: " + self.file
	    self.fail(message)
        else:
            if gssum.exists(outputfile,gsconf.baselinedb):
                sum_baseline=gssum.get_sum(outputfile,gsconf.baselinedb)
                message=myself+' checksum did not match baseline (' + outputfile + ') for input file: ' + self.file
                self.assertEqual(sum,sum_baseline,message)
            else:
                message = myself+" no baseline checksum (" + outputfile + ") for file: " + self.file
                self.fail(message)
예제 #7
0
def make_pdfcompare_entry(dbname, ifile, device, dpi, band):
    ofile = "%s.pdf.%s.%d.%d" % (ifile, device, dpi, band)
    print "creating entry: " + ofile + "...",
    sys.stdout.flush()

    if gssum.exists(ofile, dbname):
        print "exists."
        return

    gs = gstestgs.Ghostscript()

    gs.gsroot = gsconf.gsroot
    gs.log_stdout = gsconf.gs_stdout
    gs.log_stderr = gsconf.gs_stderr
    gs.command = gsconf.headinstallpath

    gs.infile = gsconf.comparefiledir + ifile
    gs.dpi = dpi
    gs.band = band

    # make file->PDF

    tfile = ofile + ".pdf"
    gs.outfile = tfile
    gs.device = 'pdfwrite'
    gs.dpi = None

    if not gs.process():
        print "error."
        return

    gs.infile = tfile
    gs.outfile = ofile
    gs.device = device
    gs.dpi = dpi

    if gs.process():
        try:
            gssum.add_file(ofile, dbname)
            rasterdb.put_file(ofile)
            os.unlink(tfile)
            os.unlink(ofile)
            print "done."
        except OSError:
            print "no output produced."
    else:
        print "error."
def regen_baseline(rasterdir, workdir, baselinedbname, filelist, options=None):
    if options == None:
        myself = "regen_baseline.py"
    else:
        myself = options.myself

    if filelist:  # filelist may be a subset of the files in rasterdir
        print filelist
        f = open(filelist)
        rasterfiles = f.readlines()
        f.close
        print rasterfiles
    else:
        rasterfiles = os.listdir(rasterdir)
        rasterfiles.sort()

    if not os.path.exists(workdir):
        os.mkdir(workdir)

    total = len(rasterfiles)
    all = 0
    print "%50s %s %i" % (rasterdir, "total files", total)
    gzmatch = re.compile('.*gz$')
    for rasterfile_raw in rasterfiles:
        if options.verbose: print "try", rasterfile_raw
        fullname = rasterdir + rasterfile_raw
        if not os.path.isfile(fullname):
            print myself, "ignoring (not regular file)", fullname
            continue
        if not gzmatch.match(rasterfile_raw):
            print myself, "ignoring (not gz)", rasterfile_raw
            continue

        rasterfile = rasterfile_raw.replace(".gz", "")
        rasterfilepath = workdir + rasterfile
        if not gssum.exists(rasterfile, baselinedbname):
            if not os.path.exists(rasterfilepath):
                if options.verbose: print "gz ", rasterfile_raw
                rasterdb.get_file(rasterfile, rasterdir, output=rasterfilepath)
            if options.verbose: print rasterfilepath
            gssum.add_file(rasterfilepath, baselinedbname)
            all += 1
            if options.verbose:
                print "%100s %i %s %i" % (rasterfile, all, "of", total)
            if options.delete and os.path.exists(rasterfilepath):
                os.unlink(rasterfilepath)
예제 #9
0
def regen_baseline(rasterdir,workdir,baselinedbname,filelist,options=None):
    if options == None:
        myself="regen_baseline.py"
    else:
        myself=options.myself

    if filelist:               # filelist may be a subset of the files in rasterdir
        print filelist
        f=open(filelist)
        rasterfiles=f.readlines()
        f.close
        print rasterfiles
    else:
        rasterfiles = os.listdir(rasterdir)
        rasterfiles.sort()

    if not os.path.exists(workdir):
        os.mkdir(workdir)

    total=len(rasterfiles)
    all=0
    print "%50s %s %i" % (rasterdir,"total files",total)
    gzmatch=re.compile('.*gz$')
    for rasterfile_raw in rasterfiles:
        if options.verbose: print "try",rasterfile_raw
        fullname=rasterdir+rasterfile_raw
        if not os.path.isfile(fullname):
            print myself,"ignoring (not regular file)",fullname
            continue
        if not gzmatch.match(rasterfile_raw):
            print myself,"ignoring (not gz)",rasterfile_raw
            continue

        rasterfile=rasterfile_raw.replace(".gz","")
        rasterfilepath=workdir+rasterfile
        if not gssum.exists(rasterfile,baselinedbname):
            if not os.path.exists(rasterfilepath):
                if options.verbose: print "gz ",rasterfile_raw
                rasterdb.get_file(rasterfile,rasterdir,output=rasterfilepath)
            if options.verbose: print rasterfilepath
            gssum.add_file(rasterfilepath,baselinedbname)
            all+=1
            if options.verbose: print "%100s %i %s %i" % (rasterfile,all,"of",total)
            if options.delete and os.path.exists(rasterfilepath):
                os.unlink(rasterfilepath)
예제 #10
0
def make_pdfcompare_entry(ifile, device, dpi, band):
    ofile = "%s.pdf.%s.%d.%d" % (ifile, device, dpi, band)
    print "creating entry: " + ofile + "...",
    sys.stdout.flush()

    if gssum.exists(ofile):
        print "exists."
        return

    gs = gstestgs.Ghostscript()
    gs.log_stdout = gsconf.log_stdout
    gs.log_stderr = gsconf.log_stderr
    gs.command = gsconf.baselinegs
    gs.infile = gsconf.comparefiledir + ifile
    gs.dpi = dpi
    gs.band = band

    # make file->PDF

    tfile = ofile + ".pdf"
    gs.outfile = tfile
    gs.device = "pdfwrite"
    gs.dpi = None

    if not gs.process():
        print "error."
        return

    gs.infile = tfile
    gs.outfile = ofile
    gs.device = device
    gs.dpi = dpi

    if gs.process():
        try:
            gssum.add_file(ofile)
            rasterdb.put_file(ofile)
            os.unlink(tfile)
            os.unlink(ofile)
            print "done."
        except OSError:
            print "no output produced."
    else:
        print "error."
    def runTest(self):
        if hasattr(self, "skip") and self.skip:
	    self.assert_(True)
	    return

        file1 = '%s.%s.%d.%d.pdf' % (self.file[string.rindex(self.file, '/') + 1:], 'pdf', self.dpi, self.band)
	file2 = '%s.pdf.%s.%d.%d' % (self.file[string.rindex(self.file, '/') + 1:], self.device, self.dpi, self.band)

	gs = gstestgs.Ghostscript()

	gs.gsroot = self.gsroot
	gs.dpi = self.dpi
	gs.band = self.band
	gs.infile = self.file
	if self.log_stdout:
	    gs.log_stdout = self.log_stdout
	if self.log_stderr:
	    gs.log_stderr = self.log_stderr

	# do file->PDF conversion
	gs.device = 'pdfwrite'
        gs.dpi = None
	gs.outfile = file1
	if not gs.process():
	    self.fail("non-zero exit code trying to create pdf file from " + self.file)

	# do PDF->device (pbmraw, pgmraw, ppmraw, pkmraw)
	gs.device = self.device
        gs.dpi = self.dpi
	gs.infile = file1
	gs.outfile = file2
	if not gs.process():
	    self.fail("non-zero exit code trying to rasterize " + file1)

        if os.path.exists(file1):
            shutil.move(file1, gsconf.datadir+"/raster.daily")
#           os.unlink(file1)
        else:
	    self.fail("output file "+file1+" was not created for input file: " + file1)
            
        if os.path.exists(file2):
            sum = gssum.make_sum(file2)
            if not sum:
                self.fail("no checksum for output file "+file2+" was not created for input file: " + self.file)
            shutil.move(file2, gsconf.datadir+"/raster.daily")
#           os.unlink(file2)
        else:
	    self.fail("output file "+file2+" was not created for input file: " + file2)
	
	# add test result to daily database
	if self.track_daily:
            if gsconf.__dict__.has_key("checksumdb") and gsconf.checksumdb:
                dbname=gsconf.dailydir+gsconf.checksumdb # mhw+".db"
            else:
                dbname=gsconf.get_dailydb_name()
            gssum.add_file(file2, dbname=dbname, sum=sum)

        else:
            outputfile=file2
            if gssum.exists(outputfile,gsconf.baselinedb):
                sum_baseline=gssum.get_sum(outputfile,gsconf.baselinedb)
                message=myself+' checksum did not match baseline (' + outputfile + ') for input file: ' + self.file
                self.assertEqual(sum,sum_baseline,message)
            else:
                message = myself+" no baseline checksum (" + outputfile + ") for file: " + self.file
                self.fail(message)