This document details how you should set up the project.
- Setup
- Configuring The Database Settings
- Project Files & Structures
- Building and Running in Development Mode
- Building and Running in Production Mode
- Commonly Faced Issues
- Other Issues
You will require the following software to be installed on your machine, before you can perform project setup with Vagrant:
- Vagrant
- VirtualBox (currently using version 5.1.18)
To setup the development environment, do the following:
- Modify the following files accordingly to match your desired PostgreSQL settings:
bootstrap.sh
in/vagrant_setup
local_database_data.py
in/components
- Click here to see how you should modify these files.
- Run the command
vagrant up
in your console/terminal to set-up the virtual environment. - Run
vagrant ssh
to enter the environment and docd csmodify
to access the project files in the environment.
You will require the following software to be installed on your machine, before you can perform project setup without Vagrant:
- Python 2.7 (currently using version 2.7.12)
- web.py
- PostgreSQL
- psycopg2
- nose
- paste
Lastly, you will need to configure local_database_data.py
. Instructions can be found here.
Our default database settings assumes that you are using the postgres
database as the postgres
user with password '12345678', using the localhost
connection at port 5432
.
Based on our understanding, the default database user is postgres
and the default database is postgres
, with no password required, with the database accessible with localhost
on port 5432
. Therefore, we expect that you will only need to change the password settings for the database.
Should your settings differ from ours, please read this section carefully.
- If you are using a different database user, you need to add commands in this file, that will:
- Create a new user in PostgreSQL
- Login to PostgreSQL with this user
- If
postgres
database does not exist in your database, you need to add a command in this file, that will create thepostgres
database for you. - If you are using a different password to login to your PostgreSQL, simply change the variable
DB_PASSWORD
in the file. - If you do not need a password to login to your PostgreSQL, you only need to remove the
ALTER USER
command that is present in the file.
- Simply modify these variables in the file to match your database settings:
database_name
user_name
password
host_name
port
- For Vagrant users: make sure that these settings tally with your modifications to
/vagrant_setup/bootstrap.sh
app.py
- The Python script for running the application
- To run the application locally, simply invoke this script using the command
python app.py
/components
- Contains all logical components for the application
- This folder contains:
/handlers
(containing Python scripts acting as handlers for web requests)database_adapter.py
(handles connection to database and database repopulation)local_database_data.py
(stores data and getters for local database connection)model.py
(acts as a facade for important logical components the database, such asdatabase.py
,helper.py
andcheck_string.py
)
/static
- This resource folder is split into:
/fonts
(for font resource files)/stylesheets
(for CSS stylesheets)/javascripts
(for JS scripts)/images
(for image resource files)
/templates
- Contains all the web.py HTML template files to be rendered by the application
/test
- Contains all test scripts
/utils
- Contains internal scripts required by the application.
.travis.yml
- Used for building the app environment in Travis CI
Procfile
- Defines how Heroku should run the application when it is deployed.
requirements.txt
- Defines the Python dependencies required by the application, when it is deployed on Heroku.
dbclean.py
- A Python script used to rebuild the aplication's database during development stage, when needed.
- You can run this script using the command
python dbclean.py
Simply set web.config.debug
to True
in app.py
, which will allow the stack trace to be displayed upon the app's failure. Once this is done, you can view your app by running python app.py
and accessing it on localhost:8080
.
Simply set web.config.debug
to False
, and you are ready to push your app out for production. You can then choose to deploy this app to the deployment platform that you desire.
To access the app, you can just access the URL where your app is deployed to.
We list down some commonly-encountered issues you might face while setting up our project, along with our suggested solutions.
-
Encountering error
chown: changing ownership of /home/vagrant/csmodify: Not a directory
after runningvagrant up
Solution: Try reinstalling VirtualBox again, then run
vagrant reload
. -
Unable to run
vagrant ssh
incmd
(for Windows users)Solution: Set your PATH variable using the command
PATH=%PATH%;C:\Program Files\Git\usr\bin
. (This assumes you already have Git Bash installed on your machine.) -
Encountering error
Stderr: VBoxManage.exe: error: VT-x is disabled in the BIOS for all CPU modes (VERR_VMX_MSR_ALL_VMX_DISABLED) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole
after runningvagrant up
Solution: Please make sure that your machine supports virtualization.
Should you face an issue related to the project setup, that you are unable to solve, you can contact us directly on GitHub, or drop us a mail at nus-dot-csmodify-at-gmail-dot-com
.