Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: can't use a string pattern on a bytes-like object #14

Closed
marcaronson408 opened this issue Oct 29, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@marcaronson408
Copy link

commented Oct 29, 2017

Received the above error when trying to run dupReport.py.

Stack trace and logifile are below.

The subject line of the email message that caused it to blow up was automatically generated by a FOSCAM IP camera.

I am not sure what the "b" is on the front of the subject line that reads,

Subject=[b'SonomaGrandroom:IPCamera SMTP test mail'].

I suspect that something funky is encoded into the byte stream of the subject line and perhaps needs to be filtered out / converted into a processable byte stream?

Any help would be greatly appreciated!

Marc

Stack trace

./dupReport.py
Traceback (most recent call last):
  File "./dupReport.py", line 861, in <module>
    process_mailbox_imap(mailBox)
  File "./dupReport.py", line 739, in process_mailbox_imap
    mParts = process_message(msg)                # Process message into parts
  File "./dupReport.py", line 470, in process_message
    if re.search(options['subjectregex'], msgParts['subject']) == None:
  File "/usr/lib/python3.4/re.py", line 170, in search
    return _compile(pattern, flags).search(string)
TypeError: can't use a string pattern on a bytes-like object

Logfile

Processing mailbox...
Message ID [<scrubbed@google.com>] does not exist. Adding to DB
Subject=[Marc, welcome to your new Google Account].
Message [<scrubbed@google.com>] is not a Message of Interest
Message ID [<scrubbed@mail.gmail.com>] does not exist. Adding to DB
Subject=[This is a test].
Message [<scrubbed@mail.gmail.com>] is not a Message of Interest
Message ID [<scrubbed@mx.google.com>] does not exist. Adding to DB
Subject=[b'SonomaGrandroom:IPCamera SMTP test mail'].

@marcaronson408

This comment has been minimized.

Copy link
Author

commented Oct 29, 2017

A quick update.

The issue is specific to the subject line I identified above. I moved that message out of the inbox and the report ran successfully.

A change that somehow properly processes those types of messages would be very helpful, as I don't have 100% control of when they get generated.

Thanks!

Marc

@HandyGuySoftware

This comment has been minimized.

Copy link
Owner

commented Oct 29, 2017

Marc,

Just to be sure I am clear, the email message in question is not from Duplicati, but from another process that sends email to your inbox? Thus it should get processed as "Not a message of interest" (but it's crashing instead)?

Just want to make sure I'm looking in the proper area of code.

Also, which version of dupReport are you running (check with -V option)? If you're on 1.0.2, can you run with the -v2 option? If on the beta branch (1.0.3), run with the -v3 option. Either way, can you run it again with the bad email in place and post the last 30 or so lines of the log file?

Thanks.

@marcaronson408

This comment has been minimized.

Copy link
Author

commented Oct 29, 2017

Thanks for the quick response!

You are correct -- this is an email that should be processed as "Not a message of interest".

-V option provides the following:

dupReport: A summary email report generator for Duplicati.
Program Version 2.0.2
Database Version 1.0.0
Copyright (c) 2017 Stephen Fried for HandyGuy Software
Distributed under MIT License. See LICENSE file for details.

Here is a link to the tail end of the logfile produced by running with the "-v2" option.

Marc

@HandyGuySoftware

This comment has been minimized.

Copy link
Owner

commented Oct 29, 2017

Marc, I just uploaded a new version of 2.0.3 on the beta branch. Please download that and run with the -v3 option and see if that works. I think I've addressed the issue, but I'm not that familiar with different email encoding schemes. If this doesn't work I'll have to do some more research.

@marcaronson408

This comment has been minimized.

Copy link
Author

commented Oct 29, 2017

That fixed the problem -- thank you very much!

Marc

@HandyGuySoftware

This comment has been minimized.

Copy link
Owner

commented Oct 29, 2017

Fixed in 2.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.