commit 7f57f34ee98594d188b9ca452da6f8672d57d3c1
parent 29744928bd6d61d85e39629bf51d8603d7693c65
Author: lash <dev@holbrook.no>
Date: Thu, 17 Nov 2022 15:12:08 +0000
Revert to correct message grouping in comment and show
Diffstat:
7 files changed, 42 insertions(+), 29 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
@@ -2,6 +2,8 @@
* GPG signing of issue messages.
* Use visitor pattern for messages verifier
* View message log in show command
+ * Show signature status with show command
+ * Add message grouping for messages added in the same comment call
? Option to dump comment attachment files when viewing with show
- 0.1.3
* Add command for adding MIME Multipart comments
diff --git a/ROADMAP b/ROADMAP
@@ -9,3 +9,5 @@
- target hash above
- git tag
- arbitrary string identifier
+- 0.2.1
+ * Render browsable HTML version of board, issues and issue logs
diff --git a/piknik/basket.py b/piknik/basket.py
@@ -187,6 +187,7 @@ class Basket:
def msg(self, issue_id, *args):
m = self.__get_msg(issue_id)
+ print('slllslsll')
m.add(*args, wrapper=self.__msg_wrap)
ms = m.as_bytes()
self.__msg.put(issue_id, ms)
diff --git a/piknik/crypto.py b/piknik/crypto.py
@@ -77,7 +77,7 @@ class PGPSigner:
if r.key_status != None:
raise VerifyError('unexpeced key status {}'.format(r.key_status))
if r.status == 'no public key':
- logg.warning('public key flr {} not found, cannot verify'.format(r.fingerprint))
+ logg.warning('public key for {} not found, cannot verify'.format(r.fingerprint))
elif r.status != 'signature valid':
raise VerifyError('invalid signature')
else:
diff --git a/piknik/msg.py b/piknik/msg.py
@@ -111,8 +111,13 @@ class IssueMessage:
return m
- def add(self, *args, related_id=None, wrapper=None):
- m_id = uuid.uuid4()
+ def add(self, *args, related_id=None, wrapper=None, message_id=None):
+ print('aaargs {}'.format(args))
+ m_id = None
+ try:
+ m_id = uuid.UUID(message_id)
+ except (ValueError, TypeError):
+ m_id = uuid.uuid4()
m = Message()
m.add_header('X-Piknik-Msg-Id', str(m_id))
m.add_header('Date', formatdate(time.time()))
diff --git a/piknik/runnable/comment.py b/piknik/runnable/comment.py
@@ -44,6 +44,7 @@ basket = Basket(store_factory, message_wrapper=signer.sign)
def main():
+ messages = []
while True:
try:
r = next_message_arg()
@@ -52,13 +53,12 @@ def main():
if r == None:
continue
- messages = []
if r[0] == 'r':
messages.append('s:' + r[1])
elif r[0] == 'f':
messages.append('f:' + r[1])
- basket.msg(arg.issue_id, *messages)
+ basket.msg(arg.issue_id, *messages)
if __name__ == '__main__':
main()
diff --git a/piknik/runnable/show.py b/piknik/runnable/show.py
@@ -15,7 +15,7 @@ from piknik import Issue
from piknik.store import FileStoreFactory
from piknik.crypto import PGPSigner
-logging.basicConfig(level=logging.DEBUG)
+#logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
argp = argparse.ArgumentParser()
@@ -34,33 +34,36 @@ class PGPWrapper(PGPSigner):
def __init__(self, home_dir=None):
super(PGPWrapper, self).__init__(home_dir=home_dir)
self.message_date = None
- self.message = None
+ self.message = []
self.message_id = None
self.sender = None
self.valid = False
- def render_message(self, envelope, message, message_id):
- r = None
- m = parse_mime_type(message.get_content_type())
+ def render_message(self, envelope, messages, message_id, w=sys.stdout):
+ r = ''
+ for message in messages:
+ m = parse_mime_type(message.get_content_type())
- if m[0] == 'text':
- if m[1] == 'plain':
- r = message.get_payload()
- if message.get('Content-Transfer-Encoding') == 'BASE64':
- r = b64decode(r).decode()
+ v = ''
+ if m[0] == 'text':
+ if m[1] == 'plain':
+ v = message.get_payload()
+ if message.get('Content-Transfer-Encoding') == 'BASE64':
+ v = b64decode(v).decode()
+ else:
+ v = '[rich text]'
else:
- r = '[rich text]'
- else:
- sz = message.get('Content-Length')
- if sz == None:
- sz = 'unknown'
- r = '[file: ' + message.get_filename() + ', size: ' + sz + ']'
+ sz = message.get('Content-Length')
+ if sz == None:
+ sz = 'unknown'
+ v = '[file: ' + message.get_filename() + ', size: ' + sz + ']'
- valid = '[++]'
- if not self.valid:
- valid = '[!!]'
- print('message {} from {} {} - {}\n\t{}\n'.format(self.sender, self.message_date, valid, message_id, r))
+ valid = '[++]'
+ if not self.valid:
+ valid = '[!!]'
+ r += '\n\t' + v + '\n'
+ w.write('\nmessage {} from {} {} - {}\n\t{}\n'.format(self.message_date, self.sender, valid, message_id, r))
def envelope_callback(self, envelope, envelope_type):
@@ -72,7 +75,7 @@ class PGPWrapper(PGPSigner):
def message_callback(self, envelope, message, message_id):
(envelope, message) = super(PGPWrapper, self).message_callback(envelope, message, message_id)
- if envelope != None and not envelope.resolved:
+ if envelope != None and not envelope.resolved:
self.sender = envelope.sender
self.valid = envelope.valid
self.resolved = True
@@ -84,14 +87,14 @@ class PGPWrapper(PGPSigner):
if message.get('Content-Type') == 'application/pgp-signature':
#return
self.render_message(envelope, self.message, self.message_id)
- self.message = None
+ self.message = []
self.message_id = None
else:
- self.message = message
- self.message_id = message_id
+ self.message.append(message)
else:
d = message.get('Date')
self.message_date = parsedate_to_datetime(d)
+ self.message_id = message_id
gpg_home = os.environ.get('GPGHOME')
verifier = PGPWrapper(home_dir=gpg_home)