Code Monkey home page Code Monkey logo

babycam's Introduction

babycam

Build Status

Babycam is a simple command line script for watching files for changes and emailing the appended content. It can be used to keep an eye on error logs and email you when an error pops up. Babycam works with Python 2.6, 2.7, 3.2, 3.3, and 3.4.

Installing

babycam is not yet on PyPI, so install with:

pip install https://github.com/luhn/babycam/archive/v1.0.1.tar.gz

Usage

usage: babycam [-h] [--host HOST] [--port PORT] [--ssl] [--tls] [--user USER]
               [--password PASSWORD] [--poll-frequency POLL_FREQUENCY]
               [--sender SENDER] [--data-dir DATA_DIR]
               recipient file [file ...]

Watch a file for changes.

positional arguments:
  recipient             The email address to send notices to.
  file                  The file(s) to watch.

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           The SMTP host.
  --port PORT           The SMTP port.
  --ssl                 Use SMTP over SSL.
  --tls                 Upgrade to TLS once connected.
  --user USER           The SMTP username.
  --password PASSWORD   The SMTP password.
  --poll-frequency POLL_FREQUENCY
                        The frequency (in seconds) to poll the files.
  --sender SENDER       The email address to use as a from address. Defaults
                        to {user}@{hostname}
  --data-dir DATA_DIR   The directory to store application data. Defaults to
                        the directory of the file.

For example:

babycam \
	--host mailtrap.io \
	--port 465 \
	--tls \
	--user 29958a97d6cf2a800 \
	--password db61946a6311c3 \
	--poll-frequency 1 \
 	[email protected] \
	file1.txt file2.txt

If you append content to file2.txt, you'll get an email like the following:

The file /Users/Luhn/Code/babycam/file2.txt has changed!

Timestamp:  2015-02-16T15:02:25.152958

See attached file for details.

Attached to this email is a text file of the appended content.

Babycam makes a small file called .[filename].babycam in the same directory as the watched file, in order to keep track of changes, so it must have write permissions to that directory. If this is not feasable, you can change the directory babycam writes to using the --data-dir argument.

If you wish to truncate a file Babycam is watching, be sure to delete the corresponding .babycam file, otherwise addendums to the truncated file will not be detected.

Daemonizing

It's often desirable to run Babycam as a daemon. To achieve this, use software such as Supervisor.

Roadmap

  • Add support for inotify so we can avoid the overhead of polling.
  • Better behavior when the file is modified rather than being appended.
    • Support truncating files without having to delete the .babycam file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.