Merge ~pappacena/launchpad:fix-sync-script-duplications into launchpad:master

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: a038c2f9229c418f7b1cdc6b29f6409154b2d334
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:fix-sync-script-duplications
Merge into: launchpad:master
Diff against target: 61 lines (+11/-4)
1 file modified
lib/lp/archivepublisher/scripts/sync_signingkeys.py (+11/-4)
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+383966@code.launchpad.net

Commit message

Adding debug messages (and fixing an INFO message) to sync-signingkey scripts. Also, forcing to commit execution at the end.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/archivepublisher/scripts/sync_signingkeys.py b/lib/lp/archivepublisher/scripts/sync_signingkeys.py
2index 38444ce..1cd56c1 100644
3--- a/lib/lp/archivepublisher/scripts/sync_signingkeys.py
4+++ b/lib/lp/archivepublisher/scripts/sync_signingkeys.py
5@@ -16,6 +16,7 @@ from datetime import datetime
6 import os
7
8 from pytz import utc
9+import transaction
10 from zope.component import getUtility
11
12 from lp.archivepublisher.config import getPubConfig
13@@ -67,6 +68,7 @@ class SyncSigningKeysScript(LaunchpadScript):
14 found_keys_per_type = {}
15 for key_type in SigningKeyType.items:
16 files = [os.path.join(dir, f) for f in keys_per_type[key_type]]
17+ self.logger.debug("Checking files %s...", ', '.join(files))
18 if all(os.path.exists(f) for f in files):
19 found_keys_per_type[key_type] = tuple(files)
20 return found_keys_per_type
21@@ -87,8 +89,11 @@ class SyncSigningKeysScript(LaunchpadScript):
22 return {}
23 for series in archive.distribution.series:
24 path = os.path.join(pubconf.signingroot, series.name)
25+ self.logger.debug("\tChecking if %s exists.", path)
26 if os.path.exists(path):
27 series_paths[series] = path
28+ self.logger.debug(
29+ "\tChecking if root dir %s exists.", pubconf.signingroot)
30 if os.path.exists(pubconf.signingroot):
31 series_paths[None] = pubconf.signingroot
32 return series_paths
33@@ -99,7 +104,8 @@ class SyncSigningKeysScript(LaunchpadScript):
34 key_type, archive, series, exact_match=True)
35 if existing_signing_key is not None:
36 self.logger.info("Signing key for %s / %s / %s already exists",
37- key_type, archive.reference, series.name)
38+ key_type, archive.reference,
39+ series.name if series else None)
40 return existing_signing_key
41
42 with open(priv_key_path, 'rb') as fd:
43@@ -119,9 +125,9 @@ class SyncSigningKeysScript(LaunchpadScript):
44 keys_per_type = self.getKeysPerType(path)
45 for key_type, (priv_key, pub_key) in keys_per_type.items():
46 self.logger.info(
47- "Found key files %s / %s (type=%s, series=%s)." %
48- (priv_key, pub_key, key_type,
49- series.name if series else None))
50+ "Found key files %s / %s (type=%s, series=%s).",
51+ priv_key, pub_key, key_type,
52+ series.name if series else None)
53 self.inject(archive, key_type, series, priv_key, pub_key)
54
55 def main(self):
56@@ -129,4 +135,5 @@ class SyncSigningKeysScript(LaunchpadScript):
57 self.logger.info(
58 "#%s - Processing keys for archive %s.", i, archive.reference)
59 self.processArchive(archive)
60+ transaction.commit()
61 self.logger.info("Finished processing archives injections.")