try except block prints 'hello'
Question:
I have a perculiar problem.
I’m using the extract_msg package to analyse a bunch of .msg files.
The package results in an NotImplementedError error when the .msg file contains attachtments.
I’m using a try-except block to catch this error, but for some weird reason its prints "hello" for every error it finds. Nowhere in my code I wrote it to print "hello" so I’m a bit baffled here.
Has anyone seen this before? And how can I avoid this strange thing from happening?
#f-variabele
f = glob.glob(r'D:AA BrendaPythonDVS_lang**.msg', recursive=True)
instead of this please do like this and try again
f = glob.glob(r'D:/AA Brenda/Python/DVS_lang/**/*.msg', recursive=True)
#loop over folders
paths =[]
senders = []
recipients = []
dates = []
subjects = []
body = []
#append data to lists:
for filename in f:
try:
msg = extract_msg.Message(filename)
paths.append(filename)
senders.append(msg.sender)
recipients.append(msg.to)
dates.append(msg.date)
subjects.append(msg.subject)
body.append(msg.body)
except NotImplementedError: #"NotImplementedError: Current version of ExtractMsg.py does not
#support extraction of containers that are not embeded msg files."
print("")
Answers:
It’s in their library:
https://github.com/TeamMsgExtractor/msg-extractor/blob/master/extract_msg/msg.py#L644
If that really bothers you, you can use the following:
How to block calls to print?
I have a perculiar problem.
I’m using the extract_msg package to analyse a bunch of .msg files.
The package results in an NotImplementedError error when the .msg file contains attachtments.
I’m using a try-except block to catch this error, but for some weird reason its prints "hello" for every error it finds. Nowhere in my code I wrote it to print "hello" so I’m a bit baffled here.
Has anyone seen this before? And how can I avoid this strange thing from happening?
#f-variabele
f = glob.glob(r'D:AA BrendaPythonDVS_lang**.msg', recursive=True)
instead of this please do like this and try again
f = glob.glob(r'D:/AA Brenda/Python/DVS_lang/**/*.msg', recursive=True)
#loop over folders
paths =[]
senders = []
recipients = []
dates = []
subjects = []
body = []
#append data to lists:
for filename in f:
try:
msg = extract_msg.Message(filename)
paths.append(filename)
senders.append(msg.sender)
recipients.append(msg.to)
dates.append(msg.date)
subjects.append(msg.subject)
body.append(msg.body)
except NotImplementedError: #"NotImplementedError: Current version of ExtractMsg.py does not
#support extraction of containers that are not embeded msg files."
print("")
It’s in their library:
https://github.com/TeamMsgExtractor/msg-extractor/blob/master/extract_msg/msg.py#L644
If that really bothers you, you can use the following:
How to block calls to print?