Re: [PATCH] devel: make printmimestructure py3 compatible

2018-06-12 Thread Tomi Ollila
On Mon, Jun 11 2018, Daniel Kahn Gillmor wrote:

> Make printmimestructure work in python3 as well as python2.
>
> PEP 394 suggests that python scripts that work with both python2 and
> python3 should have a #!/usr/bin/python command line, so do that too.

I did not see PEP 394 suggesting to change 

-#!/usr/bin/env python
+#!/usr/bin/python

just that 'python' should be able to run both python2 and python3 code.

after the above change the code will not run on (those stupid) systems
that install python to e.g. /usr/local/bin/.

While I am not against this change, the commit message is misleading.

Tomi


> ---
>  devel/printmimestructure | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/devel/printmimestructure b/devel/printmimestructure
> index 34d12930..afa0590e 100755
> --- a/devel/printmimestructure
> +++ b/devel/printmimestructure
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python
> +#!/usr/bin/python
>  # -*- coding: utf-8 -*-
>  
>  # Author: Daniel Kahn Gillmor 
> @@ -19,6 +19,8 @@
>  # If you want to number the parts, i suggest piping the output through
>  # something like "cat -n"
>  
> +from __future__ import print_function
> +
>  import email
>  import sys
>  
> @@ -34,7 +36,7 @@ def test(z, prefix=''):
>  if d[0] in [ 'attachment', 'inline' ]:
>  disposition = ' ' + d[0]
>  if (z.is_multipart()):
> -print prefix + '┬╴' + z.get_content_type() + cset + disposition + 
> fname, z.as_string().__len__().__str__() + ' bytes'
> +print(prefix + '┬╴' + z.get_content_type() + cset + disposition + 
> fname, z.as_string().__len__().__str__() + ' bytes')
>  if prefix.endswith('└'):
>  prefix = prefix.rpartition('└')[0] + ' '
>  if prefix.endswith('├'):
> @@ -47,6 +49,6 @@ def test(z, prefix=''):
>  test(parts[i], prefix + '└')
>  # FIXME: show epilogue?
>  else:
> -print prefix + '─╴'+ z.get_content_type() + cset + disposition + 
> fname, z.get_payload().__len__().__str__(), 'bytes'
> +print(prefix + '─╴'+ z.get_content_type() + cset + disposition + 
> fname, z.get_payload().__len__().__str__(), 'bytes')
>  
>  test(email.message_from_file(sys.stdin), '└')
> -- 
> 2.17.1
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] devel: make printmimestructure py3 compatible

2018-06-12 Thread Reto Brunner
On Tue, Jun 12, 2018 at 11:35:09AM +0300, Tomi Ollila wrote:
> -#!/usr/bin/env python
> +#!/usr/bin/python
> 
> just that 'python' should be able to run both python2 and python3 code.
> 
> after the above change the code will not run on (those stupid) systems
> that install python to e.g. /usr/local/bin/.
> 
> While I am not against this change, the commit message is misleading.

Remind me again why putting stuff in /usr/local is "stupid"?

/usr/bin belongs to my package manager...

If I manually compile python for whatever reason I put it in
/usr/local/bin, as this is what the directory is for.

So why would you switch from a shebang which works always to a shebang
which only works on some very simple systems? This doesn't make sense for
me.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] devel: make printmimestructure py3 compatible

2018-06-12 Thread Thomas Schneider
Tomi Ollila  writes:

> On Mon, Jun 11 2018, Daniel Kahn Gillmor wrote:
>
>> Make printmimestructure work in python3 as well as python2.
>>
>> PEP 394 suggests that python scripts that work with both python2 and
>> python3 should have a #!/usr/bin/python command line, so do that too.
>
> I did not see PEP 394 suggesting to change 
>
> -#!/usr/bin/env python
> +#!/usr/bin/python
>
> just that 'python' should be able to run both python2 and python3 code.
>
> after the above change the code will not run on (those stupid) systems
> that install python to e.g. /usr/local/bin/.

For example all BSD systems, where the package manager installs to
/usr/local (and I do not think this is stupid).

> While I am not against this change, the commit message is misleading.

For the above reason, I am against changing the shebang at all.

--qsx
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: use new show --decrypt=stash feature in emacs UI

2018-06-12 Thread Daniel Kahn Gillmor
On Mon 2018-06-11 16:09:00 -0700, Jameson Graef Rollins wrote:
> This just changes the show --decrypt flag to "stash" in the emacs UI,
> so that session keys will be stashed in the database when viewing
> encrypted messages that have not previously been decrypted.  As
> always, this will only happen if the notmuch-crypto-process-mime
> customization variable is set to "true".


I'm not convinced that this is the right approach.  In particular,
sending "--decrypt=stash" requires that the notmuch database is opened
read/write, which isn't always desirable.

(it'd be nice to be able to use notmuch-emacs to browse a notmuch
archive without locking the notmuch db or even needing read/write access
to the database)

perhaps we need a third setting for notmuch-crypto-process-mime besides
nil and t instead?

--dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] devel: make printmimestructure py3 compatible

2018-06-12 Thread Daniel Kahn Gillmor
On Tue 2018-06-12 12:47:58 +0200, Thomas Schneider wrote:
> Tomi Ollila  writes:
>
>> On Mon, Jun 11 2018, Daniel Kahn Gillmor wrote:
>>
>>> Make printmimestructure work in python3 as well as python2.
>>>
>>> PEP 394 suggests that python scripts that work with both python2 and
>>> python3 should have a #!/usr/bin/python command line, so do that too.
>>
>> I did not see PEP 394 suggesting to change 
>>
>> -#!/usr/bin/env python
>> +#!/usr/bin/python
>>
>> just that 'python' should be able to run both python2 and python3 code.
>>
>> after the above change the code will not run on (those stupid) systems
>> that install python to e.g. /usr/local/bin/.
>
> For example all BSD systems, where the package manager installs to
> /usr/local (and I do not think this is stupid).
>
>> While I am not against this change, the commit message is misleading.
>
> For the above reason, I am against changing the shebang at all.

ok, but devel/nmbug/notmuch-report uses #!/usr/bin/python, and i was
leaning toward making them consistent.  if we care about using the
/usr/bin/env trick, we should use it consistently.

i'm fine either way, my main goal with this series was to make
printmimestructure compatible with both py2 and py3, and i have no
interest in fighting about shebang lines.

 --dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 3/3] use #!/usr/bin/env python consistently

2018-06-12 Thread Daniel Kahn Gillmor
---
 devel/nmbug/notmuch-report | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/devel/nmbug/notmuch-report b/devel/nmbug/notmuch-report
index 5789c5f4..eaceb2ce 100755
--- a/devel/nmbug/notmuch-report
+++ b/devel/nmbug/notmuch-report
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 #
 # Copyright (c) 2011-2012 David Bremner 
 #
-- 
2.17.1

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 2/3] minor cleanup to printmimestructure

2018-06-12 Thread Daniel Kahn Gillmor
From: Jameson Graef Rollins 

make the source slightly easier to read.  no functional change.
---
 devel/printmimestructure | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/devel/printmimestructure b/devel/printmimestructure
index a5fc83e7..70e0a5c0 100755
--- a/devel/printmimestructure
+++ b/devel/printmimestructure
@@ -24,7 +24,7 @@ from __future__ import print_function
 import email
 import sys
 
-def test(z, prefix=''):
+def print_part(z, prefix):
 fname = '' if z.get_filename() is None else ' [' + z.get_filename() + ']'
 cset = '' if z.get_charset() is None else ' (' + z.get_charset() + ')'
 disp = z.get_params(None, header='Content-Disposition')
@@ -35,8 +35,23 @@ def test(z, prefix=''):
 for d in disp:
 if d[0] in [ 'attachment', 'inline' ]:
 disposition = ' ' + d[0]
+if z.is_multipart():
+nbytes = len(z.as_string())
+else:
+nbytes = len(z.get_payload())
+
+print('{}{}{}{}{} {:d} bytes'.format(
+prefix,
+z.get_content_type(),
+cset,
+disposition,
+fname,
+nbytes,
+))
+
+def test(z, prefix=''):
 if (z.is_multipart()):
-print(prefix + '┬╴' + z.get_content_type() + cset + disposition + 
fname, z.as_string().__len__().__str__() + ' bytes')
+print_part(z, prefix+'┬╴')
 if prefix.endswith('└'):
 prefix = prefix.rpartition('└')[0] + ' '
 if prefix.endswith('├'):
@@ -49,6 +64,6 @@ def test(z, prefix=''):
 test(parts[i], prefix + '└')
 # FIXME: show epilogue?
 else:
-print(prefix + '─╴'+ z.get_content_type() + cset + disposition + 
fname, z.get_payload().__len__().__str__(), 'bytes')
+print_part(z, prefix+'─╴')
 
 test(email.message_from_file(sys.stdin), '└')
-- 
2.17.1

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 1/3] devel: make printmimestructure py3 compatible

2018-06-12 Thread Daniel Kahn Gillmor
Make printmimestructure work in python3 as well as python2.

PEP 394 suggests that python scripts that work with both python2 and
python3 should have a #!/usr/bin/python command line, so do that too.
---
 devel/printmimestructure | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/devel/printmimestructure b/devel/printmimestructure
index 34d12930..a5fc83e7 100755
--- a/devel/printmimestructure
+++ b/devel/printmimestructure
@@ -19,6 +19,8 @@
 # If you want to number the parts, i suggest piping the output through
 # something like "cat -n"
 
+from __future__ import print_function
+
 import email
 import sys
 
@@ -34,7 +36,7 @@ def test(z, prefix=''):
 if d[0] in [ 'attachment', 'inline' ]:
 disposition = ' ' + d[0]
 if (z.is_multipart()):
-print prefix + '┬╴' + z.get_content_type() + cset + disposition + 
fname, z.as_string().__len__().__str__() + ' bytes'
+print(prefix + '┬╴' + z.get_content_type() + cset + disposition + 
fname, z.as_string().__len__().__str__() + ' bytes')
 if prefix.endswith('└'):
 prefix = prefix.rpartition('└')[0] + ' '
 if prefix.endswith('├'):
@@ -47,6 +49,6 @@ def test(z, prefix=''):
 test(parts[i], prefix + '└')
 # FIXME: show epilogue?
 else:
-print prefix + '─╴'+ z.get_content_type() + cset + disposition + 
fname, z.get_payload().__len__().__str__(), 'bytes'
+print(prefix + '─╴'+ z.get_content_type() + cset + disposition + 
fname, z.get_payload().__len__().__str__(), 'bytes')
 
 test(email.message_from_file(sys.stdin), '└')
-- 
2.17.1

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 3/3] use #!/usr/bin/env python consistently

2018-06-12 Thread Tomi Ollila
On Tue, Jun 12 2018, Daniel Kahn Gillmor wrote:

series LGTM. 

> ---
>  devel/nmbug/notmuch-report | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/devel/nmbug/notmuch-report b/devel/nmbug/notmuch-report
> index 5789c5f4..eaceb2ce 100755
> --- a/devel/nmbug/notmuch-report
> +++ b/devel/nmbug/notmuch-report
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/env python
>  #
>  # Copyright (c) 2011-2012 David Bremner 
>  #
> -- 
> 2.17.1
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] doc: document notmuch show --decrypt=stash

2018-06-12 Thread Daniel Kahn Gillmor
Help users find this new indexed-cleartext workflow.
---
 NEWS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/NEWS b/NEWS
index d1bc73b8..9c59d989 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,12 @@ Add the --full-scan option to `notmuch new`
 
   This option disables mtime based optimization of scanning for new mail.
 
+Add new --decrypt=stash option for `notmuch show`
+
+  This facilitates a workflow for encrypted messages where message
+  cleartext are indexed on first read, but the user's decryption key
+  does not have to be available during message receipt.
+
 Documentation
 -
 
-- 
2.17.1

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] devel: make printmimestructure py3 compatible

2018-06-12 Thread Daniel Kahn Gillmor
On Tue 2018-06-12 09:57:52 -0400, Daniel Kahn Gillmor wrote:
> On Tue 2018-06-12 12:47:58 +0200, Thomas Schneider wrote:
>> Tomi Ollila  writes:
>>
>>> On Mon, Jun 11 2018, Daniel Kahn Gillmor wrote:
>>>
 Make printmimestructure work in python3 as well as python2.

 PEP 394 suggests that python scripts that work with both python2 and
 python3 should have a #!/usr/bin/python command line, so do that too.
>>>
>>> I did not see PEP 394 suggesting to change 
>>>
>>> -#!/usr/bin/env python
>>> +#!/usr/bin/python
>>>
>>> just that 'python' should be able to run both python2 and python3 code.
>>>
>>> after the above change the code will not run on (those stupid) systems
>>> that install python to e.g. /usr/local/bin/.
>>
>> For example all BSD systems, where the package manager installs to
>> /usr/local (and I do not think this is stupid).
>>
>>> While I am not against this change, the commit message is misleading.
>>
>> For the above reason, I am against changing the shebang at all.
>
> ok, but devel/nmbug/notmuch-report uses #!/usr/bin/python, and i was
> leaning toward making them consistent.  if we care about using the
> /usr/bin/env trick, we should use it consistently.
>
> i'm fine either way, my main goal with this series was to make
> printmimestructure compatible with both py2 and py3, and i have no
> interest in fighting about shebang lines.

the thread starting at id:20180612212110.32533-1-...@fifthhorseman.net
has a revised series that normalizes shebang lines on

#!/usr/bin/env python

while still incorporating the fixes from myself and jamie.

  --dkg
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 1/3] devel: make printmimestructure py3 compatible

2018-06-12 Thread David Bremner
Daniel Kahn Gillmor  writes:

> Make printmimestructure work in python3 as well as python2.
>
> PEP 394 suggests that python scripts that work with both python2 and
> python3 should have a #!/usr/bin/python command line, so do that too.

I think the second paragraph is vestigal.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: use new show --decrypt=stash feature in emacs UI

2018-06-12 Thread Daniel Kahn Gillmor
On Tue 2018-06-12 10:00:18 -0400, Daniel Kahn Gillmor wrote:
> (it'd be nice to be able to use notmuch-emacs to browse a notmuch
> archive without locking the notmuch db or even needing read/write access
> to the database)

to be clear, it's not just about wanting to be able to avoid write
access during "notmuch show" -- there are other use cases i'd like us to
be able to support, including the ability to keep some messages'
cleartext indexed, while leaving some of them un-indexed (keeping their
contents secret from anyone who doesn't have the user's secret keys).

This proposed change removes that possibility, so i think it needs more
nuance.

 --dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: use new show --decrypt=stash feature in emacs UI

2018-06-12 Thread Jameson Graef Rollins
On Tue, Jun 12 2018, Daniel Kahn Gillmor  wrote:
> On Tue 2018-06-12 10:00:18 -0400, Daniel Kahn Gillmor wrote:
>> (it'd be nice to be able to use notmuch-emacs to browse a notmuch
>> archive without locking the notmuch db or even needing read/write access
>> to the database)
>
> to be clear, it's not just about wanting to be able to avoid write
> access during "notmuch show" -- there are other use cases i'd like us to
> be able to support, including the ability to keep some messages'
> cleartext indexed, while leaving some of them un-indexed (keeping their
> contents secret from anyone who doesn't have the user's secret keys).
>
> This proposed change removes that possibility, so i think it needs more
> nuance.

This patch works for all the use cases I personally care about, so I
would like a configuration that is this simple.

The use case you're arguing for, which I believe is the ability to
choose on a per-message basis whether you want to stash or not, would
have to not use the show stash functionality at all.

What if notmuch-crypto-process-mime just accepted the same values that
show --decrypt does, with the same meanings, e.g.:

┌─┬───┬──┬──┬───┐
│ │ false │ auto │ true │ stash │
├─┼───┼──┼──┼───┤
│Show  cleartext  if  session  key is │   │ X│ X│ X │
│already known│   │  │  │   │
├─┼───┼──┼──┼───┤
│Use secret keys to show cleartext│   │  │ X│ X │
├─┼───┼──┼──┼───┤
│Stash any  newly  recovered  session │   │  │  │ X │
│keys, reindexing message if found│   │  │  │   │
└─┴───┴──┴──┴───┘

notmuch-crypto-process-mime is really only relevant for show anyway, so
I think this makes sense.

Users who want to chose to stash on a per-message basis would then need
to set notmuch-crypto-process-mime=true, and then do reindex
--decrypt=true if they want to stash.

jamie.


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch