Skip to content

Commit

Permalink
Merge pull request #75 from yoniYalovitsky/patch-1
Browse files Browse the repository at this point in the history
Added basic bash functions with pre-coding steps
  • Loading branch information
MeirKriheli committed Mar 19, 2013
2 parents f57905f + dec2720 commit 9bb6daa
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/devel/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Contents:
environment/index
workflow
css_docs
ide
tips

Indices and tables
==================
Expand Down
67 changes: 62 additions & 5 deletions docs/devel/source/ide.rst → docs/devel/source/tips.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
===============
.. _devel_tips:

=========================
Development Tips
=========================

IDE setup
===============
=========

Basically you should lookup for virtualenv configuration of your preferred
development environment.


Eclipse with PyDev
======================
~~~~~~~~~~~~~~~~~~

Start by creating a new **PyDev** Project.

Expand All @@ -26,7 +31,7 @@ Start by creating a new **PyDev** Project.

In the opened window, click "New", and in the opened window "browse". Navigate
to your virtualenv and select the `python` executable in your `Scripts` folder
(for MS Windows) or `bin` (on Linux).
(for MS Windows) or `bin` (on Linux).

.. image:: pydev_interpreter.png

Expand Down Expand Up @@ -54,7 +59,7 @@ You should have something like:
Click "OK".
* Create a run configuration for your project (to make sure it'll find the
database, etc.):

* Right click the project, select "Run As" | "Run configurations".
* Right click "PyDev Django" and select "New".
* Give it a name (e.g. "oknesset Django")
Expand All @@ -64,3 +69,55 @@ You should have something like:
``runserver --noreload``.
* Click "Run", you should be able to open your browser and access
http://localhost:8000 . You can use this run configration from now on.



Useful bash functions
===================================

You can use some variation on these functions when beginning a development session (only after you finished the initial setup).
To use these, paste these functions into your ``~/.bashrc`` file and change the ``~/oknesset/`` in oknesset_activate to the directory where you installed the project's virtualencv. These functions will now be available to you in all future bash sessions, but to get it working in already opened tabs, you'll need to type ``source ~/.bashrc``.

A possible session might include:

* Open a bash tab and run ``oknesset_update`` to pull the new code and db, install any new dependencies and run the tests to check that everything is ok.
* Run ``oknesset_runserver`` in the same tab to launch the development site.
* Open another tab and run ``oknesset_activate`` to enter the Open Knesset directory (and virtualenv) to do any manual work on the files.
* Assuming you have the documentation tools set up and have changed some .rst files, run ``oknesset_makedocs`` to recreate the html pages.

.. code-block:: bash
oknesset_activate () { #Just enter the Open-Knesset directory and activate the virtualenv
cd ~/oknesset/ #or wherever you put it
source bin/activate
cd Open-Knesset
}
oknesset_update () { #Pull the new code and prepare the environment
oknesset_activate
wget http://oknesset-devdb.s3.amazonaws.com/dev.db.bz2
mv dev.db dev.db.old
bzip2 -d dev.db.bz2
git pull git@github.com:hasadna/Open-Knesset.git master
cd ..
pip install -r requirements.txt
cd Open-Knesset
./manage.py migrate
./manage.py test
}
oknesset_runserver () { #start the local server
oknesset_activate
./manage.py runserver
}
oknesset_makedocs () { #make the documentation html
oknesset_activate
pushd docs/devel >/dev/null
make html
popd >/dev/null
}
3 changes: 3 additions & 0 deletions docs/devel/source/workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ running this command event in case of no changes):
`pip install -r Open-Knesset/requirements.txt`



Run migrations and tests
--------------------------------

Expand All @@ -61,6 +62,8 @@ group to see if that's something you should worry about.
.. _oknesset-dev: https://groups.google.com/forum/#!forum/oknesset-dev


See :ref:`devel_tips` for a few bash functions that may help.

While Coding
==============

Expand Down

0 comments on commit 9bb6daa

Please sign in to comment.