List Info

Thread: help needed using the ASCIInator in roundup




help needed using the ASCIInator in roundup
user name
2007-03-22 08:12:51
hello guys,

This is an appeal for help with combining the ASCIInator
into roundup. 
I really don't know how to do it. Can someone chip in and do
it please? 
I am quite desperate to allow people to send MIME/HTML
encoded emails 
into roundup. I hate that kind of email myself and I realise
(and 
agree with) why roundup disallows it. But all should be well
by using 
the ASCIInator to convert to plaintext.

The issue is that when roundup is used by sales staff on
Windoze to 
keep track of customer queries, MIME/HTML emails will be
used. I spoke 
to the main salesman that I am encouraging to use roundup.
He said 
that image is everything and that is why people in his
sphere send and 
rcv emails with MIME/HTML. It is all about image. No extra
information 
is conveyed via the MIME/HTML, it is just done to make it
look 
'nicer'. But it is crucial that this is done. Can anyone
please help? 

The ASCIInator is otherwise known as html2text. It is a
filter written
in python that may be found at:
http://www.aar
onsw.com/2002/html2text/

I don't think the job is a huge one. It should be a case of
plugging the
ASCIInator into the email gathering pipeline at the right
point.
Slightly more involved will be an official integration so
that the next
version of roundup has optional use of the ASCIInator. It
would be a
dependency but not a mandatory one (if it's not there then
don't use
it). The author of the ASCIInator has indicated that he is
fine with
this use by roundup but that the ASCIInator (or a copy
thereof) should
not be included with the roundup distribution. So I suppose
that means
the install should ask if it is to be used, and if so, where
it is
installed.

Regards,

Andrew Marlow
----
There is an emerald here the size of a plover's egg!
Don't top-post  
http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.c
om/nomime.html


************************************************************
******************"
The data and information (collectively called Information)
herein is the sole property of ICAP.  The Information is
confidential, may be legally privileged and is intended
solely for the use of the individual or entity to whom it is
addressed.  Unauthorised disclosure, copying or distribution
of the Information is strictly prohibited and the recipient
of the Information shall not redistribute the Information in
any form to a third party.  If you received this Information
in error please tell us by reply (or telephone the sender)
and delete all copies on your system.

References in this Information to ICAP are references to
ICAP plc, a company incorporated in England with registered
number 3611426 whose registered office is 2 Broadgate, bond,
EC2M 7UR and where the context requires, includes its
subsidiary and associated undertakings.  As applicable,
certain companies within the ICAP group are authorised and
regulated by the Financial Services Authority.  Any
investment research sent from ICAP will provide an impartial
and objective assessment of the securities, companies or
other matters that are the subject of their research and our
Conflicts of Interest Management Policy regarding investment
research can be viewed by requesting a copy from your usual
contact at ICAP.  Please visit www.icap.com for further
regulatory information including details regarding the
European eCommerce Directive.

************************************************************
*******************"
We have taken precautions to minimise the risk of
transmitting software viruses, but we advise you to carry
out your own virus checks on any attachment to this message.
We cannot accept liability for any loss or damage caused by
software viruses. "
************************************************************
*******************                                         
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
                                                            
               
                                                            
                           


------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Roundup-users mailing list
Roundup-userslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/roundup-u
sers

Re: help needed using the ASCIInator in roundup
country flaguser name
Germany
2007-03-22 09:30:10
Andrew Marlow wrote:
> This is an appeal for help with combining the
ASCIInator into roundup. 
> I really don't know how to do it.

Currently, I suppose the only way is to change mailgw.py
(still dreaming of a plugin mechanism for the mail gateway
for easier customization...)

Some ideas, without knowing the module/package:

    try:
        import html2text
    except ImportError:
        html2text=None
    if html2text is not None:
        # (... do the conversion stuff...)

You might make Roundup accept mails lacking a plain text
part. I changed mailgw.py to contain the following lines:

        if content is None:
          if 'accept':       # my insertion
            content = ''     # my insertion
          else:              # my insertion
            raise MailUsageError, _("""
Roundup requires the submission to be plain text. The
message parser could
not find a text/plain part to use.
""")

(The string 'accept' is a True value and might be replaced
e.g. by an config setting)

-- 
HTH,

Tobias


------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Roundup-users mailing list
Roundup-userslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/roundup-u
sers

Re: help needed using the ASCIInator in roundup
user name
2007-03-22 10:18:30
> > This is an appeal for help with combining the
ASCIInator into roundup.
> > I really don't know how to do it.
>
> Currently, I suppose the only way is to change
mailgw.py (still dreaming
> of a plugin mechanism for the mail gateway for easier
customization...)
>
> Some ideas, without knowing the module/package:
>
>     try:
>         import html2text
>     except ImportError:
>         html2text=None
>     if html2text is not None:
>         # (... do the conversion stuff...)

In mailgw.py there are the lines:
        ...
        # accumulate the other parts
        parts = []
        while 1:
            part = self.getpart()
            if part is None:
                break
            parts.append(part)
        return parts
        ....

You might add the try/except before the while loop
and do a conversion in the body of loop.
Something like:

+        try:
+            import html2text
+        except ImportError:
+            html2text=None
        # accumulate the other parts
        parts = []
        while 1:
            part = self.getpart()
+            if html2text is not None:
+               part = html2text.html2text(part)
            if part is None:
                break
            parts.append(part)
        return parts

(Lines starting with "+" are added.)

I don't know well enough the mail standard,
it's just a wild guess that I haven't tested it.

> html2text is a filter in the UNIX sense of that word.
> It takes input from stdin and produces output on
stdout.
> It is not designed to be imported as a python module.

I don't know the author's intent but it worked:

D:descargas>d:APPSPython24python.exe
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright",
"credits" or "license" for more
information.
>>> import html2text
>>> s =
"<head>cabeza</head><body>cuerpo</
body>"
>>> html2text.html2text( s )
u'cuerpon'
>>>


> he says that roundup should not include html2text
> in the roundup distribution but roundup can call
> upon html2text as a filter than it runs.

heh... the following line can be interpreted as
a "filter" too:
   mesg = html2text.html2text( mesg )


> So no import allowed but a script can use html2text
> in its pipeline.

That a pipeline for incoming roundup emails exists or
not it depends on your setup.  For instance, in POP
mode there isn't.

Regards,
-Hernán.
------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Roundup-users mailing list
Roundup-userslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/roundup-u
sers
Re: help needed using the ASCIInator in roundup
user name
2007-03-22 10:46:38
> > So no import allowed but a script can use
html2text
> > in its pipeline.
>
> That a pipeline for incoming roundup emails exists or
> not it depends on your setup.  For instance, in POP
> mode there isn't.


Anyway, if you still want html2text to work as an
external process filter you can do something like
this:

>>> import subprocess
>>> s
'<head>cabeza</head><body>cuerpo</body&
gt;'
>>> p = subprocess.Popen(['python.exe',
'html2text.py'],
... stdin=subprocess.PIPE, stdout=subprocess.PIPE,
...
executable='/PATHTOPYTHON/python.exe').communicate(input=s)[
0]
>>> p
'cuerporn'
>>>

Regards,
-Hernán.
------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Roundup-users mailing list
Roundup-userslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/roundup-u
sers
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )