

Additionally, docopt will do validation – for example, warning the user if they enter too many arguments, something your code doesn’t do. I often use it with the of the module, like so: #!/usr/bin/env pythonĪnd now anybody reading the code can easily see what the interface to the script is, and all that messy argument parsing code has been cleaned up. You just write the help message in a standard format, and let docopt do the fiddly business of option parsing. Within the standard library, there’s argparse, which makes this a little easier, but docopt makes it easier still. You’re rolling your own argument parser, which is lots of extra code you have to write, debug and test.
#Pushbullet app scam password
You might consider providing a helper script that sets up the keychain, using getpass to ask for the password without dumping it to the console. This has the downside that it’s a bit more fiddly to set up – the user either has to use the OS’s keychain manager (if one exists), or run t_password().

Keyring.get_password('pushover', 'user_key') So, for example, rather than hard-coding an access token, you could look it up like so: import keyring Keyring provides an interface to the system keychain, so configuration is stored more securely than by mere filesystem access, and can only be accessed if the system keychain is unlocked.
#Pushbullet app scam install
Since you’re willing to install third-party packages (I see a pip install -r requirements.txt step in your README), there are a couple of packages you can install that will probably be quite useful for your code. If you are curious or find this script useful the updated version, containing many of the useful suggestions received here, is available on my GitHub # Push notification parameters (Pushbullet) # Push notification parameters (Pushover) # Please fill in your data and make sure this configuration file is not readable by other users Send_pushbullet_notification(sys.argv, sys.argv)Īnd here's the config file: # Email has been tested using and port 587 Send_email(EMAIL_SUBJECT, EMAIL_MESSAGE, EMAIL_RECIPIENTS) Print 'Pushover Example: -pushover "Message"' Print 'Pusbullet Example: -pushbullet "Title" "Message"' Print 'Email Example: -email "Email Subject" "Email Message" "Email recipients"' "token": notification_config.PUSHOVER_APP_TOKEN, This functions sends a notification using PushoverĬonn = httplib.HTTPSConnection("") ndmail(notification_config.EMAIL_SENDER, recipients, msg.as_string()) Server.login(notification_config.EMAIL_SENDER, notification_config.EMAIL_PASSWORD) If notification_config.EMAIL_DEBUG_LEVEL = '1': nnect(notification_config.EMAIL_SERVER, notification_config.EMAIL_SERVER_PORT) This functions sends a notification using EmailĮmail_recipients (str) : Email recipients. # Please put your data into configure.py before using this scriptĭef send_email(email_subject, notification_msg, email_recipients): In case anybody is much more comfortable with git than with copy/paste: git clone My main problem is that the only security offered is coming from the OS filesystem settings (making the config file not readable to other users) and I would be very happy to improve my code and make it more secure. I would be glad to receive general suggestions / feedback. I have built a tiny script to send out push notifications.
