[buildinfo.debian.net] 03/03: Add async task to update/create key ids.
Chris Lamb
chris at chris-lamb.co.uk
Thu Nov 3 20:18:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository buildinfo.debian.net.
commit 44bbd4fd96791d14a4cb4165d049badf750397dc
Author: Chris Lamb <lamby at debian.org>
Date: Thu Nov 3 20:17:48 2016 +0000
Add async task to update/create key ids.
This might need to be reworked so that Key instances always exist but then
we fill in 'name' etc. later/asynchronously.
Signed-off-by: Chris Lamb <lamby at debian.org>
---
bidb/keys/tasks.py | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/bidb/keys/tasks.py b/bidb/keys/tasks.py
new file mode 100644
index 0000000..75f7f7c
--- /dev/null
+++ b/bidb/keys/tasks.py
@@ -0,0 +1,37 @@
+import celery
+import subprocess
+
+from bidb.utils.tempfile import TemporaryDirectory
+
+from .models import Key
+
+
+ at celery.task(soft_time_limit=60)
+def update_or_create_key(uid):
+ with TemporaryDirectory() as homedir:
+ subprocess.check_call((
+ 'gpg',
+ '--homedir', homedir,
+ '--keyserver', 'http://p80.pool.sks-keyservers.net/',
+ '--recv-keys', uid
+ ))
+
+ data = subprocess.check_output((
+ 'gpg',
+ '--homedir', homedir,
+ '--with-colons',
+ '--fixed-list-mode',
+ '--fingerprint',
+ uid,
+ ))
+
+ for line in data.splitlines():
+ if line.startswith('uid:'):
+ name = line.split(':')[9]
+ break
+ else:
+ raise ValueError("Could not parse name from key: {}".format(data))
+
+ return Key.objects.update_or_create(uid=uid, defaults={
+ 'name': name,
+ })
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/buildinfo.debian.net.git
More information about the Reproducible-commits
mailing list