secure Module

The secure module provides a class with the same name which is used to represent a user’s consent to pypersonalassistant using their personal credentials.

secure Class

class pypersonalassistant.secure.secure(credentials_path='credentials.json')[source]

This class represents a user’s consent to pypersonalassistant using their personal credentials in the future.

Note

On creating an instance of this object, user input is required.

Asks the user for the password used to previously encrypt their private credentials. If it is the first time the module has been used, the password will be used to encrypt credentials entered in future.

Parameters:credentials_path (string) – The file used to retrieve/store encrypted personal credentials.
Returns:A pypersonalassistant.secure.secure object

Methods

An instance of the secure class has the following methods.

Email

secure.gmail_email(from_, to, msg)[source]

Send an email from your gmail account.

msg can either be:

  • A string, in which case:

    • At the first newline (n) the string will be split into subject and body
    • If no newline is present, the entire string will be body.
  • An email.message.Message object

Login will be performed using stored credentials.

  • stored credential name: GMAIL_EMAIL
  • stored credential name: GMAIL_EMAIL_PASSWORD
Parameters:
  • from (string) – The phone number in your twilio account to send the SMS message from. Full international format.
  • to (string) – The email address to send the email to.
  • body – The content of the email. See above.
secure.email(to, msg)[source]

Quickly send an email from a default address. Calls gmail_email().

  • stored credential name: GMAIL_EMAIL
Parameters:
  • to (string) – The email address to send the email to.
  • msg – The content of the email. See gmail_email().
secure.email_me(msg)[source]

Quickly send an email to yourself. Calls email().

  • stored credential name: PERSONAL_EMAIL
Parameters:msg – The content of the email. See gmail_email().

SMS

secure.twilio_SMS(from_, to, body)[source]

Send an SMS message from your twilio account.

Login will be performed using stored credentials.

  • stored credential name: TWILIO_ACCOUNT_SID
  • stored credential name: TWILIO_AUTH_TOKEN
Parameters:
  • from (string) – The phone number in your twilio account to send the SMS message from. Full international format.
  • to (string) – The phone number to send the SMS message to. Full international format.
  • body (string) – The content of the SMS message.
secure.SMS(to, body)[source]

Quickly send an SMS from a default number. Calls twilio_SMS().

  • stored credential name: TWILIO_PHONE_NUMBER
Parameters:
  • to (string) – The phone number to send the SMS message to. Full international format.
  • body (string) – The content of the SMS message.
secure.SMS_me(body)[source]

Quickly send an SMS to yourself. Calls SMS().

  • stored credential name: PERSONAL_PHONE_NUMBER
Parameters:body (string) – The content of the SMS message.

Raw credentials

secure.credential(key)[source]

Returns the decrypted (plain-text) value of the credential specified.

Parameters:key (string) – The credential name.
Returns:The credential value as a string.
secure.edit_credentials(credential=None, already_set=True)[source]

Edit the credentials used by the secure class.

Note

User input is required.

By default, unset credentials will be displayed.

Parameters:
  • credential (string) – A specific credential to edit.
  • already_set (bool) – If False will show all credentials, whether set or unset.

Attributes

secure.credentials_path

The path to the file containing encrypted personal credentials

Type:string