| 36 |
|
|
| 37 |
cursor.execute("PREPARE uh_insert AS INSERT INTO %s (id, package, \ |
cursor.execute("PREPARE uh_insert AS INSERT INTO %s (id, package, \ |
| 38 |
version, date, changed_by, changed_by_name, changed_by_email, maintainer, maintainer_name, maintainer_email, nmu, signed_by, signed_by_name, signed_by_email, key_id, fingerprint) VALUES \ |
version, date, changed_by, changed_by_name, changed_by_email, maintainer, maintainer_name, maintainer_email, nmu, signed_by, signed_by_name, signed_by_email, key_id, fingerprint) VALUES \ |
| 39 |
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)" % self.my_config['table']) |
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)" % self.my_config['table']) |
| 40 |
cursor.execute("PREPARE uh_arch_insert AS INSERT INTO %s (id, \ |
cursor.execute("PREPARE uh_arch_insert AS INSERT INTO %s (id, \ |
| 41 |
architecture) VALUES \ |
architecture) VALUES \ |
| 42 |
($1, $2)" % (self.my_config['table'] + '_architecture')) |
($1, $2)" % (self.my_config['table'] + '_architecture')) |
| 43 |
cursor.execute("PREPARE uh_close_insert AS INSERT INTO %s (id, bug) \ |
cursor.execute("PREPARE uh_close_insert AS INSERT INTO %s (id, bug) \ |
| 44 |
VALUES ($1, $2)" % (self.my_config['table'] + '_closes')) |
VALUES ($1, $2)" % (self.my_config['table'] + '_closes')) |
| 45 |
|
|
| 46 |
id = 0 |
id = 0 |
| 47 |
query = "EXECUTE uh_insert(%(id)s, %(Source)s, %(Version)s, %(Date)s, \ |
query = "EXECUTE uh_insert(%(id)s, %(Source)s, %(Version)s, %(Date)s, \ |
| 51 |
%(Fingerprint)s)" |
%(Fingerprint)s)" |
| 52 |
query_archs = "EXECUTE uh_arch_insert(%(id)s, %(arch)s)" |
query_archs = "EXECUTE uh_arch_insert(%(id)s, %(arch)s)" |
| 53 |
query_closes = "EXECUTE uh_close_insert(%(id)s, %(closes)s)" |
query_closes = "EXECUTE uh_close_insert(%(id)s, %(closes)s)" |
| 54 |
uploads = () |
uploads = [] |
| 55 |
uploads_archs = () |
uploads_archs = [] |
| 56 |
uploads_closes = () |
uploads_closes = [] |
| 57 |
for name in glob(path + '/debian-devel-changes.*'): |
for name in glob(path + '/debian-devel-changes.*'): |
| 58 |
# print name |
# print name |
| 59 |
f = None |
f = None |
| 60 |
if name.endswith(".gz"): |
if name.endswith(".gz"): |
| 61 |
f = gzip.open(name) |
f = gzip.open(name) |
| 62 |
else: |
else: |
| 63 |
f = open(name) |
f = open(name) |
| 64 |
current = {'id': id} |
current = {'id': id} |
| 65 |
current['Fingerprint'] = 'N/A' # hack: some entries don't have fp |
current['Fingerprint'] = 'N/A' # hack: some entries don't have fp |
| 66 |
last_field = None |
last_field = None |
| 67 |
line_count = 0 |
line_count = 0 |
| 68 |
|
|
| 69 |
for line in f: |
for line in f: |
| 70 |
line_count += 1 |
line_count += 1 |
| 71 |
line = line.strip() |
line = line.strip() |
| 72 |
# Stupid multi-line maintainer fields *grml* |
# Stupid multi-line maintainer fields *grml* |
| 73 |
if line == '': |
if line == '': |
| 74 |
current['Changed-By_name'], current['Changed-By_email'] = email.Utils.parseaddr(current['Changed-By']) |
current['Changed-By_name'], current['Changed-By_email'] = email.Utils.parseaddr(current['Changed-By']) |
| 75 |
current['Maintainer_name'], current['Maintainer_email'] = email.Utils.parseaddr(current['Maintainer']) |
current['Maintainer_name'], current['Maintainer_email'] = email.Utils.parseaddr(current['Maintainer']) |
| 76 |
current['Signed-By_name'], current['Signed-By_email'] = email.Utils.parseaddr(current['Signed-By']) |
current['Signed-By_name'], current['Signed-By_email'] = email.Utils.parseaddr(current['Signed-By']) |
| 77 |
uploads += (current,) |
uploads.append(current) |
| 78 |
for arch in set(current['Architecture'].split()): |
for arch in set(current['Architecture'].split()): |
| 79 |
current_arch = {'id': id} |
current_arch = {'id': id} |
| 80 |
current_arch['arch'] = arch |
current_arch['arch'] = arch |
| 81 |
uploads_archs += (current_arch,) |
uploads_archs.append(current_arch) |
| 82 |
if current['Closes'] != 'N/A': |
if current['Closes'] != 'N/A': |
| 83 |
for closes in set(current['Closes'].split()): |
for closes in set(current['Closes'].split()): |
| 84 |
current_closes = {'id': id} |
current_closes = {'id': id} |
| 85 |
current_closes['closes'] = closes |
current_closes['closes'] = closes |
| 86 |
uploads_closes += (current_closes,) |
uploads_closes.append(current_closes) |
| 87 |
if len(uploads) > 100: |
id += 1 |
| 88 |
cursor.executemany(query, uploads) |
current = {'id': id} |
| 89 |
cursor.executemany(query_archs, uploads_archs) |
current['Fingerprint'] = 'N/A' # hack: some entries don't have fp |
| 90 |
cursor.executemany(query_closes, uploads_closes) |
last_field = None |
| 91 |
uploads = () |
continue |
|
uploads_archs = () |
|
|
uploads_closes = () |
|
|
id += 1 |
|
|
current = {'id': id} |
|
|
current['Fingerprint'] = 'N/A' # hack: some entries don't have fp |
|
|
last_field = None |
|
|
continue |
|
| 92 |
|
|
| 93 |
if line.find(':') == -1: |
if line.find(':') == -1: |
| 94 |
if not last_field: |
if not last_field: |
| 95 |
raise Exception, "Format error on line " + line_count + "of file " + name |
raise Exception, "Format error on line " + line_count + "of file " + name |
| 96 |
current[last_field] += line |
current[last_field] += line |
| 97 |
continue |
continue |
| 98 |
|
|
| 99 |
(field, data) = line.split(':', 1) |
(field, data) = line.split(':', 1) |
| 100 |
data = data.strip() |
data = data.strip() |
| 101 |
current[field] = data |
current[field] = data |
| 102 |
|
|
| 103 |
last_field = field |
last_field = field |
| 104 |
|
|
| 105 |
cursor.executemany(query, uploads) |
cursor.executemany(query, uploads) |
| 106 |
cursor.executemany(query_archs, uploads_archs) |
cursor.executemany(query_archs, uploads_archs) |