Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found

Cible

Sélectionner le projet cible
  • la-quadrature-du-net/memopol/memopol
  • lnclt/political_memory
  • arthur/political_memory
  • agrausem/political_memory
  • periode/memopol
  • Anthony/memopol
  • Porkepix/memopol
  • jaster/memopol
  • luxcem/memopol
  • TAlone/memopol
10 résultats
Afficher les modifications
Validations sur la source (917)
Affichage de
avec 235 ajouts et 183 suppressions
[run]
omit =
src/representatives_positions/contrib/*
src/representatives_recommendations/contrib/*
src/representatives/tests/*
src/representatives/migrations/*
src/representatives/contrib/francedata/tests/*
src/representatives/contrib/parltrack/tests/*
src/representatives_votes/tests/*
src/representatives_votes/migrations/*
......@@ -3,18 +3,37 @@ celerybeat-*
core/static/libs/*
# libs
static/libs
src/memopol/static/libs/
# settings
memopol/config.json
# settings
src/memopol/local_settings.py
src/memopol/config.json
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
.cache
.coverage
*.egg-info
# Virtualenv
memopol_env
.tox
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
.dpl
db.sqlite
*.sqlite
*.json.xz
log/
/data
data/
# editors
*~
# local setup
.memopol.alias
whoosh_index/
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
cache:
paths:
- "$CI_PROJECT_DIR/pip-cache"
key: "$CI_PROJECT_ID"
stages:
- test
- deploy
before_script:
- pip install --user tox
- export PATH="$HOME/.local/bin:$PATH"
unit tests:
stage: test
script: tox -e py27
tags: [memopol]
qa checks:
stage: test
script: tox -e qa
tags: [memopol]
docs build:
stage: test
script: git diff --raw HEAD^1 | grep docs || tox -e docs
tags: [memopol]
docs deploy:
stage: deploy
script:
- source /srv/memopol/memopol_env/bin/activate
- cd /srv/memopol/memopol_env/src/memopol/docs
- make html
tags: [memopol]
environment: production
only:
- master
django deploy:
stage: deploy
script:
- source /srv/memopol/memopol_env/bin/activate
- cd /srv/memopol/memopol_env/src/memopol
- git fetch origin
- git reset --hard origin/master
- find . -name '*.pyc' -delete
- find . -name '__pycache__' | xargs rm -rf
- rm -r src/*.egg-info
- pip install -Ue .
- src/memopol/bin/install_client_deps.sh
- memopol migrate --noinput
- memopol collectstatic --noinput
- touch /srv/memopol/ready
tags: [memopol]
environment: production
only:
- master
The OpenShift `python` cartridge documentation can be found at:
http://openshift.github.io/documentation/oo_cartridge_guide.html#python
For information about .openshift directory, consult the documentation:
http://openshift.github.io/documentation/oo_user_guide.html#the-openshift-directory
For information about action hooks, consult the documentation:
http://openshift.github.io/documentation/oo_user_guide.html#action-hooks
export OPENSHIFT_PYTHON_WSGI_APPLICATION=memopol/wsgi.py
#!/bin/bash
# This deploy hook gets executed after dependencies are resolved and the
# build hook has been run but before the application has been started back
# up again. This script gets executed directly, so it could be python, php,
# ruby, etc.
set -xe
source ${OPENSHIFT_HOMEDIR}app-root/runtime/dependencies/python/virtenv/bin/activate
pip install -U pip
pip install -Ue ${OPENSHIFT_REPO_DIR}
pushd ${OPENSHIFT_REPO_DIR}
if [ -f ${OPENSHIFT_DATA_DIR}sentry ]; then
pip install raven
./manage.py raven test
else
echo ${OPENSHIFT_DATA_DIR}sentry does not exist, not setting up raven.
fi
python ${OPENSHIFT_REPO_DIR}manage.py migrate --noinput
PATH="${OPENSHIFT_DATA_DIR}node/bin:$PATH"
HOME=$OPENSHIFT_DATA_DIR
CI=true
bin/install_client_deps.sh
mkdir -p wsgi
./manage.py collectstatic --noinput
./manage.py compress
popd
mkdir -p ${OPENSHIFT_DATA_DIR}media
mkdir -p ${OPENSHIFT_REPO_DIR}wsgi/static/media
ln -sf ${OPENSHIFT_DATA_DIR}media ${OPENSHIFT_REPO_DIR}wsgi/static/media
ln -sf ${OPENSHIFT_DATA_DIR}compress/CACHE ${OPENSHIFT_REPO_DIR}wsgi/static/collected/CACHE
Run scripts or jobs on a periodic basis
=======================================
Any scripts or jobs added to the minutely, hourly, daily, weekly or monthly
directories will be run on a scheduled basis (frequency is as indicated by the
name of the directory) using run-parts.
run-parts ignores any files that are hidden or dotfiles (.*) or backup
files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved}
The presence of two specially named files jobs.deny and jobs.allow controls
how run-parts executes your scripts/jobs.
jobs.deny ===> Prevents specific scripts or jobs from being executed.
jobs.allow ===> Only execute the named scripts or jobs (all other/non-named
scripts that exist in this directory are ignored).
The principles of jobs.deny and jobs.allow are the same as those of cron.deny
and cron.allow and are described in detail at:
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-Automating_System_Tasks.html#s2-autotasks-cron-access
See: man crontab or above link for more details and see the the weekly/
directory for an example.
PLEASE NOTE: The Cron cartridge must be installed in order to run the configured jobs.
For more information about cron, consult the documentation:
http://openshift.github.io/documentation/oo_cartridge_guide.html#cron
http://openshift.github.io/documentation/oo_user_guide.html#cron
#!/bin/bash
set -x
cmd=$1
cd $OPENSHIFT_REPO_DIR
export CLEAN=1
nohup bin/update_all > $OPENSHIFT_LOG_DIR/update_all.log 2>&1 &
Run scripts or jobs on a weekly basis
=====================================
Any scripts or jobs added to this directory will be run on a scheduled basis
(weekly) using run-parts.
run-parts ignores any files that are hidden or dotfiles (.*) or backup
files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} and handles
the files named jobs.deny and jobs.allow specially.
In this specific example, the chronograph script is the only script or job file
executed on a weekly basis (due to white-listing it in jobs.allow). And the
README and chrono.dat file are ignored either as a result of being black-listed
in jobs.deny or because they are NOT white-listed in the jobs.allow file.
For more details, please see ../README.cron file.
Time And Relative D...n In Execution (Open)Shift!
#!/bin/bash
echo "`date`: `cat $(dirname \"$0\")/chrono.dat`"
#
# Script or job files listed in here (one entry per line) will be
# executed on a weekly-basis.
#
# Example: The chronograph script will be executed weekly but the README
# and chrono.dat files in this directory will be ignored.
#
# The README file is actually ignored due to the entry in the
# jobs.deny which is checked before jobs.allow (this file).
#
chronograph
#
# Any script or job files listed in here (one entry per line) will NOT be
# executed (read as ignored by run-parts).
#
README
For information about markers, consult the documentation:
http://openshift.github.io/documentation/oo_user_guide.html#markers
sudo: false
env:
- DJANGO_DEBUG=True DJANGO_SETTINGS_MODULE=memopol.settings
global:
- DJANGO_DEBUG=True
- DJANGO_SETTINGS_MODULE=memopol.settings
matrix:
- TOXENV=qa
- TOXENV=docs
- TOXENV=py27
language: python
python:
- '2.7'
before_install:
- pip install codecov
- '3.4'
services:
- postgresql
install:
- pip install -e .[testing]
- travis_retry pip install -U pip
- travis_retry pip install tox
- travis_retry pip freeze
before_script:
- bin/install_client_deps.sh
- psql -c "CREATE USER memopol WITH CREATEDB PASSWORD 'memopol';" -U postgres
- psql -c "CREATE DATABASE memopol WITH OWNER memopol;" -U postgres
script:
- bash -c '! lesscpy -N static/less/base.less 2>&1 | grep Error'
- flake8 . --exclude '*/migrations,docs,static' --ignore E128
- py.test memopol representatives_positions representatives_recommendations
- rm -rf db.sqlite
- django-admin migrate
- travis_retry tox
after_success:
- codecov
deploy:
- provider: openshift
edge: true
user: memopol@laquadrature.net
password:
secure: atDq1NEkHXOsV2gZKeXAIn+PvbL3jduz3WK1qIs7BSHyNbrZMT1OUmvoXXrM8+i5eqW3TNsvp23w0RuD06wxSjHkPl+ZCEXP1Ao98p85UZNCgixxiwZHEhL6Amz5vqueGhv+47VOIKNgNFb9NAtRrWyIdA9xDUiK2oWkMSDmHas=
......@@ -27,15 +33,4 @@ deploy:
domain: memopol
deployment_branch: master
on:
repo: political-memory/political_memory
branch: master
- provider: openshift
user: memopol@laquadrature.net
password:
secure: atDq1NEkHXOsV2gZKeXAIn+PvbL3jduz3WK1qIs7BSHyNbrZMT1OUmvoXXrM8+i5eqW3TNsvp23w0RuD06wxSjHkPl+ZCEXP1Ao98p85UZNCgixxiwZHEhL6Amz5vqueGhv+47VOIKNgNFb9NAtRrWyIdA9xDUiK2oWkMSDmHas=
app: v3
domain: memopol
deployment_branch: v3
on:
repo: political-memory/political_memory
branch: v3
repo: memopol/memopol master
[![Build Status](https://travis-ci.org/political-memory/political_memory.svg?branch=master)](https://travis-ci.org/political-memory/political_memory)
[![codecov.io](https://codecov.io/github/political-memory/political_memory/coverage.svg?branch=master)](https://codecov.io/github/political-memory/political_memory?branch=master)
[![build status](https://git.laquadrature.net/memopol/memopol/badges/master/build.svg)](https://git.laquadrature.net/memopol/memopol/commits/master)
[![coverage report](https://git.laquadrature.net/memopol/memopol/badges/master/coverage.svg)](https://git.laquadrature.net/memopol/memopol/commits/master)
git clone git@github.com:political-memory/political_memory.git
cd political_memory
# Create a throwable virtualenv
virtualenv ve
source ve/bin/activate
# Install python requirements
pip install -r requirements.txt
# Create the local db
python manage.py migrate
# Install browser libs
bin/install_client_deps.sh
# In another terminal (don't forget to activate the venv)
./manage.py runserver
[Manual](http://memopol.readthedocs.io/en/master/index.html)
\ No newline at end of file
#!/bin/bash
# Script to setup few usual aliases to facilitate the development
# This aliases should work if you've installed memopol throught the quickstart
# script or the documentation
# It :
# - Setup automaticaly the venv
# - Setup Django in DEBUG mode
# You just need to add a line in you're .bashrc or .zshrc to load them:
REPOROOT="$( readlink -m "${BASH_SOURCE[0]}"/../..)"
ALIASROOT=$REPOROOT"/.memopol.alias"
echo $ALIASROOT
echo "Create a dedicated alias file in $ALIASROOT"
echo "alias memopol-code=\"cd $REPOROOT && source $REPOROOT/memopol_env/bin/activate && export DJANGO_DEBUG=True\"" > $ALIASROOT
echo "alias memopol-launch=\"memopol-code && memopol runserver\"" >> $ALIASROOT
echo "alias memopol-update-all=\"memopol-code && bin/update_all\"" >> $ALIASROOT
echo "alias memopol-refresh-scores=\"memopol-code && memopol refresh_scores\"" >> $ALIASROOT
case $SHELL in
*/bash)
echo "Bash detected"
echo "Update $HOME/.bashrc file"
RCSHELL="$HOME/.bashrc"
;;
*/zsh)
echo "Zsh detected"
echo "Update $HOME/.zshrc file"
RCSHELL="$HOME/.zshrc"
;;
*)
echo "SHELL not supported. Try using BASH or ZSH, or set alias manually."
RCSHELL="/dev/null"
;;
esac
echo "source $ALIASROOT" >> $RCSHELL
source $ALIASROOT
echo -e "You can use the following aliases :\n"
echo -e "\t memopol-code : Go into the repository and activate the virtualenv"
echo -e "\t memopol-launch : Run the development server"
echo -e "\t memopol-update-all : Get all the production data"
echo -e "\t memopol-refresh-scores : Refresh all scores"
if [ -n "$OPENSHIFT_HOMEDIR" ]; then
source ${OPENSHIFT_HOMEDIR}app-root/runtime/dependencies/python/virtenv/bin/activate
fi
function pipe_download_to_command() {
if [ -n "$OPENSHIFT_DATA_DIR" ]; then
cd $OPENSHIFT_DATA_DIR
fi
function parltrack_download_pipe() {
[ -n "$CLEAN" ] && rm -rf $1
[ -f "$1" ] || wget http://parltrack.euwiki.org/dumps/$1 || exit 1
if [ -n "$OPENSHIFT_REPO_DIR" ]; then
cd $OPENSHIFT_REPO_DIR
fi
export DJANGO_SETTINGS_MODULE=memopol.settings
unxz -c ${OPENSHIFT_DATA_DIR}$1 | $2
[ -n "$CLEAN" ] && rm -rf $1
}
function francedata_download_pipe() {
[ -n "$CLEAN" ] && rm -rf $1
[ -f "$1" ] || wget https://memopol.lqdn.fr/fd/$1 || exit 1
export DJANGO_SETTINGS_MODULE=memopol.settings
gunzip -c ${OPENSHIFT_DATA_DIR}$1 | $2
[ -n "$CLEAN" ] && rm -rf $1
}
function refresh_scores() {
export DJANGO_SETTINGS_MODULE=memopol.settings
memopol refresh_scores
}
#!/bin/bash
#
# Quick-start script for new developers
# Usage: from repo root, `source bin/quickstart.sh`
#
REPOROOT=$(dirname $(dirname $0))
# Ensure we're at the root of the memopol repository
pushd $REPOROOT >/dev/null
# Create & activate python virtual environment
virtualenv memopol_env
source memopol_env/bin/activate
# Install python dependencies
pip install -U pip setuptools
pip install -e .[testing]
# Install client dependencies
src/memopol/bin/install_client_deps.sh
# Create pg user and database
if [ $(psql -c "select 'CNT=' || count(1) from pg_catalog.pg_user where usename='memopol';" -U postgres | grep CNT=1 | wc -l) -lt 1 ]; then
psql -c "create user memopol with password 'memopol';" -U postgres
fi
psql -c "alter role memopol with createdb;" -U postgres
if [ $(psql -l -U postgres | egrep "^ memopol\W" | wc -l) -lt 1 ]; then
psql -c "create database memopol with owner memopol;" -U postgres
fi
# Setup environment
export DJANGO_DEBUG=True
export DJANGO_SETTINGS_MODULE=memopol.settings
# Run django migration to create database
memopol migrate
# Import sample data
memopol loaddata data_sample.json
memopol refresh_scores
# Build index for Whoosh
memopol rebuild_index
echo
echo "You're all set!"
echo "To start the application run the following from the repository root ($REPOROOT):"
echo " source memopol_env/bin/activate"
echo " export DJANGO_DEBUG=True DJANGO_SETTINGS_MODULE=memopol.settings"
echo " memopol runserver"
echo
echo "If you make changes, don't forget to run tests using:"
echo " flake8 . --exclude '*/migrations,docs,static' --ignore E128"
echo " py.test memopol representatives_positions representatives_recommendations"
echo
echo "Happy hacking ;)"
echo
popd >/dev/null