[ale] A question for the python gurus

Charles Shapiro hooterpincher at gmail.com
Fri Jun 1 09:23:50 EDT 2012


Looks like mutt is not running your script right.  I can't comment on
that configuration issue.

Python  is complaining that the variable "string" is a null (like, not
initialized to anything).  Python is a dynamic, strongly typed
language, so the only way it knows what something _is_ is if it's used
before. A proximate fix to this particular error would be to
initialize "string" to a null string before line 26, e.g. ' string =
"" '.

After examining the script, that might even workee.  But it looks like
the real trouble is that the script is expecting an email message with
headers (like, "Date:", "From:", "Subject:", and "Message-ID:" on
stdin. Looks like it parses out those headers and does some Stuff with
the message.  No headers -> no strings -> uninitialized variable ->
abend.  Your message is what I get if I simply run the script from the
command line.  If I create a test message:


cat > t.txt
Date: 06012012
From: cshapiro at tomshiro.org
Subject: Test Message
Message-ID:  21430981234098123098123098123


This is a test message.
^d

And then run that through this thing:

python mutt-to-omnifocus.py < t.txt

I get:

sh: osascript: not found


Presumably you have an "osascript" command somewhere in your $PATH. Of
course, if you were a really Cool Guy you'd test for the presence of
email headers on stdin somewhere in the script and report a proper
error message if you didn't find them (e.g. "Null or invalid message
found" ).  Then you could contact the original author with a fix.
Betcha he'd respond to that.

-- CHS

On Fri, Jun 1, 2012 at 8:57 AM, Trey Sizemore <trey at fastmail.fm> wrote:
> This is more of a Python question than a linux question, but I know
> there's
> some tremendous python knowledge on the list, so feel free to delete or
> ignore.
>
> I tried messaging the script's author with no response.
>
> I found a script here[1] I want to use with mutt that will allow me to
> send messages to OmniFocus.  I have copied the script to my $PATH, but
> when I invoke it (with CTRL-L) in mutt, I get the following errors:
>
> Traceback (most recent call last):
>  File "/usr/local/bin/mutt-to-omnifocus.py", line 110, in <module>
>    main()
>  File "/usr/local/bin/mutt-to-omnifocus.py", line 101, in main
>    send_to_omnifocus(parse_message(raw), quickentry=True)
>  File "/usr/local/bin/mutt-to-omnifocus.py", line 58, in
>  send_to_omnifocus
>    note = "\n".join(["%s: %s" % (k, applescript_escape(v)) for (k, v)
>    in params])
>  File "/usr/local/bin/mutt-to-omnifocus.py", line 26, in
>  applescript_escape
>    string = string.replace('\\', '\\\\')
> AttributeError: 'NoneType' object has no attribute 'replace'
> Press any key to continue...
>
> Any idea as to what the issue is?
>
> Thanks!
>
> [1] https://github.com/andrewlkho/mutt-to-omnifocus/tree/
>
> --
>  Trey Sizemore
>  trey at fastmail.fm
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo



More information about the Ale mailing list