Fix minor cron.py issues

Related to #63: TypeError: memoryview: a bytes-like object is required, not
'str'.

- Allow GnuPG.add_key accept either 'str' or 'bytes'.
- Import MIMEText from email.mime.text.
This commit is contained in:
Piotr F. Mieszkowski 2022-04-10 19:03:18 +02:00
parent c4e9e3e840
commit 5a34249090
2 changed files with 3 additions and 1 deletions

View File

@ -102,6 +102,8 @@ def confirm_key( content, email ):
# adds a key and ensures it has the given email address
def add_key( keyhome, content ):
if type(content) == 'str':
content = bytes(content, sys.getdefaultencoding())
p = subprocess.Popen( build_command(keyhome, '--import', '--batch'), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
p.communicate(input=content)
p.wait()

View File

@ -25,7 +25,7 @@ import MySQLdb
import smtplib
import markdown
import syslog
from email.MIMEText import MIMEText
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
def appendLog(msg):