JavaScript CSS Python HTML
Pull request Compare This branch is 970 commits ahead, 4 commits behind ronreiter:master.
Latest commit 303f91b Feb 14, 2017 @danielhers danielhers committed on GitHub Merge pull request #668 from ChaosPredictor/dev
3 tests checking markers severity response: fatal/severve/light and change of clusters range
Permalink
Failed to load latest commit information.
alembic/versions #558 - Added basic user preferences. Next - need to add validation fo… Mar 8, 2016
docs Add instructions for loading new CBS data Feb 12, 2017
static removed code from changeDate function in app.js Jan 30, 2017
templates Merge pull request #656 from voronovmax/fix-#637-Change_css_styles_of… Jan 23, 2017
tests Merge pull request #668 from ChaosPredictor/dev Feb 14, 2017
translations/he/LC_MESSAGES Update to dev Oct 12, 2015
.buildpacks Adding specific build pack to install java 1.8 for closure compiler (… Nov 10, 2014
.gitignore remove .DS_Store and add it to .gitignore Closes #638 Jan 5, 2017
.travis.yml first set of tests on top of Flask Jan 20, 2017
Anyway.ai work Aug 17, 2013
Dockerfile add Dockerfile that deply anyway from local code base, that enable to… May 23, 2016
LICENSE Update app name to ANYWAY (all caps) May 7, 2015
Procfile Adding new relic for monitoring perofrmance Nov 10, 2014
README.md Update README.md Feb 6, 2017
app.json Add Heroku generated app.json May 1, 2015
babel.cfg Update to dev Oct 12, 2015
base.py - Clearing sessions after each request Nov 3, 2014
clusters_calculator.py Fix debug prints in cluster calculation Oct 22, 2015
config.py start working on #594 - hide the footer, as well, upon map_only setting. Jun 12, 2016
constants.py cleanup Constants class Jun 27, 2016
crontab Add crontab for loading data from United Nov 29, 2016
database.py - Clearing sessions after each request Nov 3, 2014
docker-compose.yml change docker-compose port to 80 Jun 4, 2016
field_names.py #301 + #302 - to dev branch. Jun 15, 2015
fields work Aug 17, 2013
globalmaptiles.py Clustering moved to server-side. Still slow - needs work May 18, 2015
importmail.py #591 replace print() with logging in some places May 22, 2016
load_discussions.py #591 replace print() with logging in some places May 22, 2016
localization.py Fix #585: remove MEZEG_AVIR_UNITED from localization.py May 17, 2016
main.py refactor the json creation to code to use the build-in jsonify function Jan 30, 2017
messages.pot Update to dev Oct 12, 2015
models.py #417 - Added involved by age and sex chart + added an optimization fo… Sep 2, 2016
newrelic.ini Adding new relic for monitoring perofrmance Nov 10, 2014
oauth.py #517 - added basic google login. Feb 2, 2016
process.py Set delete_all to False by default Feb 12, 2017
requirements.txt Partial fix for #534: add weather data for new United accidents May 15, 2016
runtime.txt Update Python to 2.7.11 May 6, 2016
save_discussions.py Script to print all discussion identifiers from DB May 22, 2015
simple_import.py advanced shared constants system Jun 27, 2016
united.py Remove --newformat flag, guess format from file header Feb 4, 2017
utilities.py Fixed markers, working on discussion marker Sep 23, 2015

README.md

ANYWAY

oway.org.il - Crowd-sourced road hazard reporting website.

Feel free to contribute to the project.

To report bugs and feature requests, please open an issue on GitHub.

See also our Android app on GitHub.

See documentation for our source dataset.

See Code Directory Tree Structure.

Contributing

  • We try to follow the process of other Hasadna projects, e.g. Open-Knesset.
  • Please take a moment to read our "Contibuting to ANYWAY" manifest.
  • To see our GitHub issues in a nicer interface, take a look at HuBoard. Check out the Ready list to find a task to work on. The Backlog list there contains issues that are still not ready to be started. The Working list contains issues already started by developers (make sure to move your issue there once you start working on it), and the Done list contains completed issues that are waiting to be confirmed done and closed.

Development environment setup notes

Choose one of two environment setup options:
  1. Local installation:

Getting the code

  1. Fork this repository on GitHub
  2. git clone https://github.com/*you*/anyway
  3. Add the main repository as your upstream remote: git remote add upstream https://github.com/hasadna/anyway

  • Get updates whenever you start working: git pull upstream dev
  • Push to your fork when you've committed your changes and tested them: git push, and make a pull request from your fork on GitHub

Installing dependencies

Ubuntu

sudo apt-get install python-pip python-dev python-tk libpq-dev

OS X

  1. sudo easy_install pip setuptools
  2. Install postgresql: brew install postgresql (after installing brew)

Both Ubuntu and OS X: virtualenv setup

  1. sudo pip install virtualenvwrapper
  2. Add to your ~/.bashrc:

    source /usr/local/bin/virtualenvwrapper.sh

    (Assuming it exists. Otherwise, it might be in /usr/bin/virtualenvwrapper.sh, so use that instead in that case.)

  3. source ~/.bashrc
  4. mkvirtualenv anyway
  5. cd anyway
  6. pip install -r requirements.txt

  • Each time you start working: workon anyway

Windows (experimental)

  1. Install Python 2.7.11
    • If Python is already installed and its version is lower than 2.7.11 update to a version >= 2.7.11 OR install setuptools & pip(package manager)
  2. Update the PATH to include a reference to the Python and Python/scripts directories (replace C:\Python27 with your path to Python).
    • Command Line: Run this command with Administrator privileges: SETX /M PATH "%PATH%";C:\Python27;C:\Python27\Scripts. The new path will be available in the next opened terminal.
    • GUI: Control Panel > System Properties > Advanced > Environment Variables > System Variables > Path > Edit > Add ;C:\Python27;C:\Python27\Scripts to the end of the line.
  3. Install VC2008 Express (alt: mingw)
  4. Install PostgreSQL ( x86 version! even if you have 64 bit os )
    • Add its bin folder to your path: C:\Program Files (x86)\PostgreSQL\9.4\bin\
  5. Install GitHub for windows and get the code
  6. cd to the anyway directory
  7. pip install -r requirements.txt
    • If any package fails to install, download it from here and install it using pip install <package>.
    • If this fails, you might have to download the win32 package, even if you are on a 64-bit platform.
    • Currently, the packages pyproj and psycopg2 are failing to install so for both of them, you need to download and install the cp27 win32 version, even if you have a 64 bit Windows version installed.

Creating a cloud development environment on c9

  1. Create an account at c9.io (preferably with github verification, but can also be done with a simple IP address

  2. Create a new public python based project that receives code from https://github.com/hasadna/anyway repository

  3. Preform git checkout dev After the Clone activity is completed (can take a few minutes) run the following:

    • sudo pip install -r requirements.txt
    • export DATABASE_URL='sqlite:///local.db'
    • python models.py
    • python process.py
  4. Go to configurations page (using the top right configuration icon) go to the Run Configuration part and press Add New config

  5. Do the following definitions on the window that just popped up:

    • Definition Name - Anyway
    • File to be run - main.py
    • Press enter to save the setting.
    • Environment variables - DATABASE_URL sqlite:///local.db (in two different colums)
  6. Set this to be the default by selecting the definitions window and pressing Set As Default

  7. Run the environment by pressing Run Application and see it by pressing Preview and then Preview Running Application

Local first run (all platforms)

  1. Define connection string (needs to be defined whenever you start working):

    • bash: export DATABASE_URL='sqlite:///local.db'
    • windows shell: set DATABASE_URL=sqlite:///local.db
  2. First time, create tables: python models.py

  3. Optionally, get the complete accidents file after sending a permission request, and extract it into /static/data/lms. Otherwise you'll use the example accidents file that you already got with the code, so no need to get it again.
  4. Populate the data (markers etc.): python process.py: this will take less than an hour if you're using the example files (default), but if you have the complete data it may take several days. Be prepared.
  5. Populate united hatzala sample data: python united.py --light for the complete, or more recent data please contact the Anyway team.
  6. Run the app: python main.py: do this whenever you start working and want to try out your code.
  7. Navigate to http://127.0.0.1:5000 in your browser.
  8. If the site fails to load properly, make sure you have JDK installed on your machine
  9. If you wish to share your app on the local network you can expose flask by running python main.py --open (Please note that this would expose your machine on port 5000 to all local nodes)

It is useful to add the following to your ~/.bashrc (fixing for the correct path):

alias anyway='cd *path*/anyway && workon anyway && export DATABASE_URL=sqlite:///local.db'

Then you can simply start working by running the anyway command.

IDE

PyCharm is recommended for development.

You can do most of the setup through PyCharm:

  1. After getting the code, open the anyway directory in PyCharm.
  2. Set up a virtualenv: File -> Settings -> Project -> Project Interpreter -> Click the cog icon at the top right -> Create VirtualEnv. Name it "anyway" and choose Python 2.7.11 as the base interpreter.
  3. Restart PyCharm, and when it asks whether to install the packages from requirements.txt, answer Yes.
  4. Right click models.py and choose Run 'models', then click the dropdown menu at the top that says models and click Edit Configurations. Under Environment, click the ... next to Environment variables and add the variable DATABASE_URL with the value sqlite:///local.db. Then click OK twice and run models.py again.
  5. Run process.py the same way (adding the DATABASE_URL variable).
  6. Run united.py the same way, but in Edit Configurations, also add --light in the Script parameters.
  7. Run main.py the same way (without --light).
  8. Navigate to http://127.0.0.1:5000 in your browser.

Testing

Server side testing can be done by adding python tests under tests folder, using a test_*.py file name pattern.

To run tests: python -m unittest discover ./tests.

Heroku deployment

  1. Create an account on Heroku
  2. Install the Heroku toolbelt
  3. Follow the quickstart instructions. On step #4, read the Python introduction
  4. Create an app, e.g. anyway-you
  5. Sign up for a free Heroku Postgres add-on (note that you'll have to enter your credit card details to be eligible): heroku addons:add heroku-postgresql:hobby-dev
  6. Push from your Git repository to Heroku
  7. Populate the database with the data (assuming you have it in your local directory):
    1. Copy the database URL from your Heroku config: heroku config:get DATABASE_URL (if you have several apps, specify the relevant one with the option --app <anyway-*you*> for any Heroku command)
    2. Create tables: python models.py
    3. Populate data: python process.py
  8. Navigate to http://anyway-you.herokuapp.com

Docker

See DOCKER

Translation and Localization

See TRANSLATE