Commit 7d19e69c authored by Chris Lamb's avatar Chris Lamb 💬

Apply black to bidb.keys.tasks now that it is valid Python [3.x].

parent 99ebf5fc
...@@ -11,24 +11,32 @@ from .models import Key ...@@ -11,24 +11,32 @@ from .models import Key
def update_or_create_key(uid): def update_or_create_key(uid):
with TemporaryDirectory() as homedir: with TemporaryDirectory() as homedir:
try: try:
check_output2(( check_output2(
'gpg', (
'--homedir', homedir, 'gpg',
'--keyserver', 'pgpkeys.mit.edu', '--homedir',
'--recv-keys', uid, homedir,
)) '--keyserver',
'pgpkeys.mit.edu',
'--recv-keys',
uid,
)
)
except subprocess.CalledProcessError as exc: except subprocess.CalledProcessError as exc:
print("E: {}: {}".format(exc, exc.output)) print("E: {}: {}".format(exc, exc.output))
return None, False return None, False
data = check_output2(( data = check_output2(
'gpg', (
'--homedir', homedir, 'gpg',
'--with-colons', '--homedir',
'--fixed-list-mode', homedir,
'--fingerprint', '--with-colons',
uid, '--fixed-list-mode',
)) '--fingerprint',
uid,
)
)
for line in data.splitlines(): for line in data.splitlines():
if line.startswith('uid:'): if line.startswith('uid:'):
...@@ -37,9 +45,8 @@ def update_or_create_key(uid): ...@@ -37,9 +45,8 @@ def update_or_create_key(uid):
else: else:
raise ValueError("Could not parse name from key: {}".format(data)) raise ValueError("Could not parse name from key: {}".format(data))
return Key.objects.update_or_create(uid=uid, defaults={ return Key.objects.update_or_create(uid=uid, defaults={'name': name})
'name': name,
})
@celery.task() @celery.task()
def refresh_all(): def refresh_all():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment