<commit_before># PulseGuardian

A system to manage Pulse: creates users and handle overgrowing queues. More
information on [the wiki][].

[![Build Status](https://travis-ci.org/mozilla/pulseguardian.svg?branch=master)](https://travis-ci.org/mozilla/pulseguardian)

## Pre-requisites

* RabbitMQ (tested on 3.3.0)
* Python 2.7
* pip (to install external dependencies)
* PostgreSQL (for production; testing environments can use sqlite)

## Setup

See the mozillapulse [HACKING.md][] file for instructions on setting
up a local Pulse environment.  You can also use a docker container.  There
are no proper docs for this yet, but see the functions in
`test/docker_setup.py`, which create an image and container running
RabbitMQ, forwarding the AMQP and management API ports from 5672 and 15672
to 5673 and 15673 on the local host, respectively.

TODO: Docker is a more lightweight solution than Vagrant and should be
considered the preferred way.  We need docs here, and the mozillapulse
package's tests should be updated to use docker instead of Vagrant.

Using a virtualenv is highly recommended. One possible installation would be

* Clone the repository and cd into it.
* Create and activate a virtualenv:

  ```
    virtualenv venv
    source venv/bin/activate
  ```

Within the chosen environment, install and configure PulseGuardian:

* Install the requirements:

  ```
    pip install -r requirements.txt
  ```

* Set environment variables as necessary for your local settings.  See
  `pulseguardian/config.py`.

Because Persona requires an https connection, if you are running the
development server without the `--fake-account` option (see below), you
will also need the pyOpenSSL package:

    pip install pyOpenSSL

## Usage

Make sure `rabbitmq-server` is running and you're inside the source directory
(`pulseguardian`) before you run the following commands.

Note that tests are run on [Travis CI][]. Before submitting a patch,
it is highly recommended that you get a Travis CI account and
activate it on a GitHub fork of the pulseguardian repo. That way the
reviewer can quickly verify that all tests still pass with your changes.

* Initialize the db with: `python dbinit.py`. *WARNING*: This removes any
  existing data the app might have previously stored in the databse.
* Optional: Generate some dummy data (dummy user account, admin account):
  `python dbinit.py --dummy`
* Run the Pulse Guardian daemon with: `python guardian.py`
* Run the web app (for development) with:
  `python web.py --fake-account <EMAIL>`
* For production, the web app can be run with [gunicorn][] and such.

The fake account option will make development easier. This feature will
disable HTTPS and bypass Persona for testing. It will also create the
given user, if necessary, and log in automatically.

## Testing
<commit_msg>Clarify installation/test instructions further.<commit_after># PulseGuardian

A system to manage Pulse: creates users and handle overgrowing queues. More
information on [the wiki][].

[![Build Status](https://travis-ci.org/mozilla/pulseguardian.svg?branch=master)](https://travis-ci.org/mozilla/pulseguardian)

## Pre-requisites

* RabbitMQ (tested on 3.3.0)
* Python 2.7
* pip (to install external dependencies)
* PostgreSQL (for production; testing environments can use sqlite)

## Setup

Using a virtualenv is highly recommended. One possible installation would be

* Clone the repository and cd into it.
* Create and activate a virtualenv:

  ```
    virtualenv venv
    source venv/bin/activate
  ```

Within the chosen environment, install and configure PulseGuardian:

* Install the requirements:

  ```
    pip install -r requirements.txt
  ```

* Set environment variables as necessary for your local settings.  See
  `pulseguardian/config.py`.

Because Persona requires an https connection, if you are running the
development server without the `--fake-account` option (see below), you
will also need the pyOpenSSL package:

    pip install pyOpenSSL

You will also need a RabbitMQ instance running somewhere.  Docker provides a
lightweight and isolated solution; however, there are no proper docs for this
yet.  You can use the functions in `test/docker_setup.py` to create an image
and container running RabbitMQ, which also forwards the AMQP and management
API ports from 5672 and 15672 to 5673 and 15673 on the local host,
respectively.

You can also use either a local RabbitMQ server or a VM.  See the
mozillapulse [HACKING.md][] file for instructions on setting up both of these.

TODO: Add a script and docs to start up a Docker instance.

## Usage

Make sure `rabbitmq-server` is running, your environment variables are
configured properly, and that you're inside the source directory
(`pulseguardian`) before you run the following commands.

Note that tests are run on [Travis CI][]. Before submitting a patch,
it is highly recommended that you get a Travis CI account and
activate it on a GitHub fork of the pulseguardian repo. That way the
reviewer can quickly verify that all tests still pass with your changes.

* Initialize the db with: `python dbinit.py`. *WARNING*: This removes any
  existing data the app might have previously stored in the databse.
* Optional: Generate some dummy data (dummy user account, admin account):
  `python dbinit.py --dummy`
* Run the Pulse Guardian daemon with: `python guardian.py`
* Run the web app (for development) with:
  `python web.py --fake-account <EMAIL>`
* For production, the web app can be run with [gunicorn][] and such.

The fake account option will make development easier. This feature will
disable HTTPS and bypass Persona for testing. It will also create the
given user, if necessary, and log in automatically.

## Testing

{'fraction_non_alphanumeric': 0.06695804195804196, 'fraction_numerical': 0.008041958041958041, 'mean_word_length': 4.371830985915493, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6355840', 'n_tokens_mistral': 1625, 'n_tokens_neox': 1500, 'n_words': 782}