1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
#!/usr/bin/env python
# -*- Mode: python -*-
# Copyright (C) 2001-2020 Artifex Software, Inc.
# All Rights Reserved.
#
# This software is provided AS-IS with no warranty, either express or
# implied.
#
# This software is distributed under license and may not be copied,
# modified or distributed except as expressly authorized under the terms
# of the license contained in the file LICENSE in this distribution.
#
# Refer to licensing information at http://www.artifex.com or contact
# Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
# CA 94945, U.S.A., +1(415)492-9861, for further information.
#
#
# compare_checksumdb.py firstname secondname
#
# this script provides the difference between two sets of checksums
# the files must be anydbm files, ususally with the testfile name as the key
version="1.0"
import sys, os
import optparse, myoptparse
import anydbm
if __name__ == "__main__":
optionsParser=optparse.OptionParser()
optionsParser.add_option('--option',action='store_true',help="sample additional option")
optionsParser.add_option('--nosvn',action='store_true',help="no not update from svn")
optionsParser.add_option('--nomake',action='store_true',help="no not make")
(options,arguments)=myoptparse.parseCommandLine(optionsParser)
print options.revision
old_dbname=arguments.pop(0)
new_dbname=arguments.pop(0)
print myself,old_dbname,new_dbname
try:
old_db = anydbm.open(old_dbname, 'r')
except:
old_db=None
print myself,"ERROR: Test results for %s %s were not found." % (old_name,old_dbname)
try:
new_db = anydbm.open(new_dbname, 'r')
except:
new_db=None
print myself,"ERROR: Test results for %s %s were not found." % (new_name,new_dbname)
if not old_db:
print myself,"empty checksum database",old_dbname
if not new_db:
print myself,"empty checksum database",new_dbname
if not new_db or not old_db:
normal_re = re.compile("^(.*?)\.(p[bgpk]mraw)\.(\d+)\.(\d+)$")
pdfwrite_re = re.compile("^(.*?)\.(ps|pdf)\.pdf\.(p[bgpk]mraw)\.(\d+)\.(\d+)$")
diffs = []
keys = new_db.keys()
for k in keys:
if k in baseline_db.keys():
if new_db[k] != baseline_db[k]:
all_diffs.append(k)
if k in old_db.keys():
if old_db[k] == baseline_db[k]:
new_diffs.append(k) # new mismatch
continue
list = []
for d in new_diffs:
type = ''
filename = ''
device = ''
dpi = 0
banded = 0
m = pdfwrite_re.search(d)
if m:
type = 'pdfwrite'
filename = m.group(1) + "." + m.group(2)
device = m.group(3)
dpi = int(m.group(4))
banded = int(m.group(5))
else:
m = normal_re.search(d)
if m:
type = 'normal '
filename = m.group(1)
device = m.group(2)
dpi = int(m.group(3))
banded = int(m.group(4))
if not type:
print myself,"WARNING: unknown device",d
continue
if banded:
bandstr = "banded"
else:
bandstr = "noband"
list.append((type, filename, device, dpi, bandstr))
length = len(list)
if length>0:
print
print myself,new_name,"new differences from",old_name,"(",str(length)," differences)"
list.sort()
for l in list:
print "%s %s (%s/%d/%s)" % (l[0], l[1], l[2], l[3], l[4])
else:
print myself,new_name,"0 differences from",old_name
list = []
for d in all_diffs:
type = ''
filename = ''
device = ''
dpi = 0
banded = 0
m = pdfwrite_re.search(d)
if m:
type = 'pdfwrite'
filename = m.group(1) + "." + m.group(2)
device = m.group(3)
dpi = int(m.group(4))
banded = int(m.group(5))
else:
m = normal_re.search(d)
if m:
type = 'normal '
filename = m.group(1)
device = m.group(2)
dpi = int(m.group(3))
banded = int(m.group(4))
if not type:
print myself,"WARNING: unknown device",d
continue
if banded:
bandstr = "banded"
else:
bandstr = "noband"
list.append((type, filename, device, dpi, bandstr))
length = len(list)
if length > 0:
print
print myself,new_name,"differences from baseline ("+str(length)+" differences)"
list.sort()
for l in list:
print "%s %s (%s/%d/%s)" % (l[0], l[1], l[2], l[3], l[4])
else:
print myself,new_name,"0 differences from baseline",baseline_db_path
|