rasbt / pyprind

PyPrind - Python Progress Indicator Utility
BSD 3-Clause "New" or "Revised" License
547 stars 65 forks source link

Task Complete Email #8

Open DevMoore94 opened 9 years ago

DevMoore94 commented 9 years ago

I figured I would open an issue to discuss possible solutions to the email notification. User privacy is important and it appears the available solutions could be pretty limited. So as far as privacy, we shouldn't be able to tell who and where an email is being sent correct?

rasbt commented 9 years ago

Thanks for open a separate issue; it makes it simpler to keep the discussions organized! I think it should be some solution where we don't collect the email addresses of the users or information about their tasks. It sound a little bit cumbersome this way... But I think of being a user myself: I wouldn't feel comfortable if someone would be able to collect my user data e.g., when I ran certain task (especially if it is some work related stuff and a user wants to use descriptive labels). Honestly, I have no real idea if there are some libraries where something like that has already been implemented. But I'd be happy to do some research on that (some time after Nov 13 -- have some very important deadlines on this day I have to focus on right now)

rasbt commented 9 years ago

And if it is not so easily doable (sorry, I haven't thought about the privacy issue initially when I had this idea) don't worry about implementing an email feature for now; it was just an idea and it is not really so important! And thanks for your general interest in improving PyPrind, I really appreciate it

DevMoore94 commented 9 years ago

No Problem at all! Just happy to be part of the project.

rasbt commented 9 years ago

I just saw an article that might be very helpful for achieving this task:

Sending Email using Python http://trevorappleton.blogspot.co.uk/2014/11/sending-email-using-python.html

So, instead of providing the email in the ProgBar initialization, we can prompt for a configuration file, e.g., ProgBar(email_config='path_to_config_file')

Where the config file contains something like

SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
USERNAME = 'your_username@gmail.com'
PASSWORD = 'your_gmail_password' 

However, we have to think about how to store the password. It should be at least encrypted somehow, otherwise it is really too dangerous to save the password somewhere in plain text on your computer

The only question would be how

DevMoore94 commented 9 years ago

Encryption probably wouldn't be too bad. My. Concern is that sending an email to yourself through Gmail smtp limits this to only people with a Gmail account would it not?

rasbt commented 9 years ago

Hey, Brandon, this was just an example, I assume that it works with most email providers. E.g., I just tested my icloud address (with smtp.mail.me.com) and it worked too. However, I couldn't get it to work with my edu address yet. I assume that it is a little bit tricky and requires some more testing.

I have to read more about the differences between ports, SSL, TLS, and STARTTLS. But I think that we can build something that tries to send the email first via e.g., the method that is posted in the blog article and if it raises an exception, we can try those SSL or TLS things.

DevMoore94 commented 9 years ago

Wouldn't this require setting up servers for each different email provider?

rasbt commented 9 years ago

Right, but I think this is all something that can go in a separate config file that a user needs to setup one time like I posted above:

SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
USERNAME = 'your_username@gmail.com'
PASSWORD = 'your_gmail_password' 

I just had the thought, what about a separate function in PyPrind, e.g, pyprind.setup_email(...) that the user only has to run once (unless he wants to change settings) to setup such a config file? PyPrind would then generate an encrypted file with this information maybe in its own module directory so that every time in future when a user wants to receive an email conformation, he/she can initialize the ProgBar like pyprind.ProgBar(..., email=True) -- and if it can't find the config file it will print a warning message with instructions for the user.

DevMoore94 commented 9 years ago

That sounds like a great idea! Seems to be the most logical solutions to the problem when factoring in privacy.

rasbt commented 9 years ago

Agree:) I think it is not only privacy but also security! I would feel very uncomfortable if I would have to store my password in plain text somewhere on my computer. Also, if I would picture myself as a user who is using someone else's tool to send "job completion" notifications, I would feel more comfortable if it is kind of anonymous.

I just stumbled across an article in a weekly Python newsletter that I thought might be relevant for encryption: "ENCRYPTING FILES WITH PYCRYPTO" http://brainacle.com/encrypting-files-with-pycrypto.html

DevMoore94 commented 9 years ago

I will have a look at this article and see if I can pull some ideas together. :)

DevMoore94 commented 9 years ago

Still not entirely sure how I would want to go about doing this.

DevMoore94 commented 8 years ago

Hey Sorry It's been a long time haha. Is this still a feature that would be useful to have?

rasbt commented 8 years ago

@DevMoore94 No worries! Personally, I would find such a feature very useful for certain applications. The approach using smtplib (see the link to the post above) sounds pretty reasonable to me; I haven't tested it yet, though.

dzaytsev91 commented 7 years ago

@rasbt Hey, I read your thought about email notifications and created a pull request, I will be very please for your comments about it, this is my first open source experience, please don't be too harsh :)