Skip to content

Latest commit

 

History

History
128 lines (95 loc) · 5.08 KB

bot.md

File metadata and controls

128 lines (95 loc) · 5.08 KB

Build Bot From Source

Built and running using macOS 12.3.1 and Python 3.10.3.

Steps

  1. Install Mac dependencies.
  2. Configure Mac dependencies.
  3. Install Python dependencies.
  4. Set configurations in app.py.

Install Mac Dependencies

Please double check all main sites before running code hardcorded here, just in case the maintainers' instructions have changed.

Xcode Command Line Tools

  • Required for Homebrew.
    xcode-select --install

Homebrew

  • A package manager, in this case used for installing Python-related tools.
  • Homebrew

PostgreSQL

  • An open-source, relational database system.
  • Postgres.app offers an easy installation.

pyenv

  • Used to install and manage different versions of Python.
  • pyenv (install using Homebrew)
    brew update
    brew install pyenv

pyenv-virtualenv

  • Used to manage a virtual environment for this app's Python version and its specific dependencies.
  • pyenv-virtualenv (install using Homebrew)
    brew update
    brew install pyenv-virtualenv

Configure Mac Dependencies

PostgreSQL

  • After completing the Postgres.app install steps, start the PostgreSQL server.
  • To create a new database, in your Terminal app, run:
    createdb cscrub

pyenv

See pyenv's COMMANDS.md for additional usage info.

  • View list of available Python versions and install 3.10.3 (or later, but not fully tested).

    pyenv install --list
    pyenv install version
    
    # i.e. pyenv install 3.10.3

pyenv-virtualenv

See pyenv-virtualenv's GitHub for additional usage info.

  • Create a new virtual environment specifying the preferred Python version from your installs.

    pyenv virtualenv 3.10.3 name-of-virtualenv
    
    # i.e. pyenv virtualenv 3.10.3 cscrub3.10.3
  • In the cscrub directory, add a .python-version file. Inside this file, write the name of the virtual environment to auto-activate the virtualenv.

    # Inside .python-version, for example:
    
    cscrub3.10.3

Install Python Dependencies

  • All dependencies below can be automatically installed using the requirements.txt file.
    pip install -r requirements.txt
  • To see what this command installs, or to install the components separately, please see below.

Selenium

Webdriver Manager

psycopg2-binary

  • psycopg2-binary is an adapater for PostgreSQL.
    pip install psycopg2-binary

SQLAlchemy

  • SQLAlchemy is an ORM to map Python objects to PostgreSQL tables.
    pip install sqlalchemy

feedparser

  • feedparser helps parse an RSS feed.
    pip install feedparser

Set Configurations in app.py

  • A CONFIGURATIONS section at the top of app.py allows for customizing the bot's actions.

create_tables_in_db

  • TRUE: creates tables in the database.
  • This should be run as TRUE at least once.

add_members_to_db

  • TRUE: fetches and adds City Council members to the Alderpersons table.

add_meetings_to_db

  • TRUE: fetches and adds City Council meeetings to the Meetings table.

add_legislation_to_db

  • TRUE: fetches and adds legislation from each meeting to the Legislation table.
  • This option can be further customized using set_legislation_links_list and links_list.

set_legislation_links_list

  • FALSE, by default: the bot will fetch legislation for every meeting in the database.
  • To override this behavior, and only fetch legislation from specific meetings, set this option to TRUE.
  • Use links_list to set which meetings to fetch legislation from.

links_list

  • Accepts an array of Meetings links.
  • Each meeting in the database has a link column.
  • To set which meeting to fetch legislation from, obtain the meeting's link, and append to the links_list variable.
  • When set_legislation_links_list is set to TRUE, the bot will only fetch legislation for the meetings appended to links_list.