Pushbullet

Experiments may crash, so you probably watch their outputs every few minutes to make sure it is still running or restart it in the worst case. Now, there’s no need to keep an eye on the output anymore! By using this code, you will receive a message in your mobile phone and desktop browser if a log file is not updated often enough. You can also send messages at any time, for example, when the experiment finishes.

The code below sends a message if a file is not updated in 5 minutes. The script will keep running until it sends a message or it is killed.

from expyrimenter.apps import Pushbullet

pb = Pushbullet()
pb.monitor_file('~/outputs/long_experiment.log', 5 * 60)

To send a message:

from expyrimenter.apps import Pushbullet

pb = Pushbullet()
# To send a message, inform title and an optional body
pb.send_note('Experiment finished!')

Before using it, you must install pushbullet mobile app and/or browser add-on. Then, go to the Pushbullet web site, access your account settings (last time, it was by clicking in the avatar), copy the Access Token and paste it in your ~/.expyrimenter/config.ini like this (check expyrimenter.Config for more details about general configuration):

[pushbullet]
token = your_pushbullet_access_token
class expyrimenter.apps.Pushbullet[source]

Requires [pushbullet] section with token value in config. Check expyrimenter.Config for more details about configuration.

monitor_file(filename, max_mod_interval, title=None, body=None)[source]

Sends a message if filename is not modified within max_mod_interval seconds. When a message is sent, it stops monitoring the file. Otherwise, it keeps running until it is killed.

Parameters:
  • filename (str) – The filename to be monitored
  • max_mod_interval (int) – If filename is not modified within max_mod_interval seconds, a message will be sent
  • title (str) – Optional message title
  • body (str) – Optional message body content
send_note(title='', body='')[source]

Sends a message using pushbullet note type.

Parameters:
  • title (str) – Optional message title
  • body (str) – Optional message body content