koodaamo / tnefparse

a TNEF decoding library written in python, without external dependencies
GNU Lesser General Public License v3.0
49 stars 37 forks source link

Update cmdline.py #63

Closed Sam-Gracy closed 4 years ago

Sam-Gracy commented 4 years ago

This code change is needed to fix the below issue. t = TNEF(open(filename).read(), do_checksum=True) ## filename is winmail.dat File "/usr/lib/python3.7/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9f in position 1: invalid start byte

jugmac00 commented 4 years ago

Hi @Sam-Gracy

your changes break the test suite, see here https://travis-ci.org/github/koodaamo/tnefparse/jobs/689966889

Especially this is the problem:

NameError: name 'filename' is not defined

I am still not sure how you use this package. Do you import it into your Python code or do you install it and run the command line script?

I tested the cli script with no problem here.

It would be helpful if you describe what you do in more detail (usage as a Python module or as a cli script), and maybe show some more of your code.

petri commented 4 years ago

I guess the issue #62 this PR was supposed to resolve was itself resolved and this PR can be closed right?

Sam-Gracy commented 4 years ago

Hi,

I have imported this library and using it in my sample program to extract the content of the winmail.dat. filename is the variable which holds the path+name of winmail.dat.

filename = os.path.join(filePath, "winmail.dat") if filename: t = TNEF(open(filename, 'rb').read(), do_checksum=True) ## filename is winmail.dat

t = TNEF(filename.read(), do_checksum=True)

    else:
        sys.exit("Raw-Email is not in Rich Text Format")
jugmac00 commented 4 years ago

Hi @Sam-Gracy

thanks for getting back!

So, obviously, there is nothing to fix in this package here, but you need to fix the part where you read the file.

This is also shown in the README:

>>> from tnefparse import TNEF
>>> with open("tests/examples/one-file.tnef", "rb") as tneffile:
...    tnefobj = TNEF(tneffile.read())

If this is ok for you, you could probably close the pull request.

P.S.: Your code imports the TNEF class from tnef.py (via __init__.py) and you tried to fix the problem in cmdline.py - so even if there would have been a problem in this package, it probably would have been the wrong spot.

Sam-Gracy commented 4 years ago

I am sorry, I misread the code. Thanks alot for your explanation. I am closing the request.