SDStore and Python 3

My PhD supervisor has a project called SD Store which is designed to simplify the storage and retrieval of sensor data. It has been used in multiple research projects and has a number of plugins. It is currently being ported to Python 3, but if you want to try it out you will need a little help. In this post I have outlined the steps I took to get it up and running.

Do you have Python 3?

Run the following command and you should see something like this: Python 3.5.2.

python --version

If you don’t, then head over to Python.org to download and install it.

Make a project directory

On your machine create a folder called sdstore-demo. You can call it whatever you like, but I will stick to this naming convention for now. Now open terminal and move to the directory e.g. cd ~/Documents/sdstore-demo.

Create a virtual environment

Virtual environments are great as they keep your projects’ dependencies isolated. They allow you to have different versions of the same libraries installed on the same machine at the same time without having to mess around each time you switch projects. I recommend using Anaconda to manage your virtual environments, but Pipenv is the officially recommended Python 3 packaging tool. I am not going to repeat the install instructions here, head over to Anaconda or Pipenv and get setup.

To create a Python 3 virtual environment and activate it with Anaconda:

conda create --name sdstore-demo
source activate sdstore-demo

To create a Python 3 virtual environment with Pipenv (no need to activate):

pipenv --python 3.6

Create a Django project

Next we need to create a Django project. We do that by first using the ‘pip’ command to install Django and then create a new project.

pip install django==1.11
django-admin startproject sdstore-demo

Now step into the new project folder.

cd sdstore-demo

Create a local database for testing.

python manage.py migrate

Create a super user by inputting the following command and following the instructions.

python manage.py createsuperuser

And we can test the project by calling:

python manage.py runserver

Why a folder in a folder? Well I like to keep files associated with a project, but not part of the running server nearby. For example, if you have Photoshop files which you use to create JPEG files.

Installing SDStore

We are going to add SDStore and its companion basicutils as git sub modules.

git init
git submodule add https://bitbucket.org/ecostanza/sd_store.git
git submodule add https://bitbucket.org/ecostanza/basicutils.git

Now we need to switch both these submodules to Python 3 branches.

cd sd_store
git checkout django1.11-python3.6
cd ../

and…

cd basicutils
git checkout django1.8-python3.6
cd ../

Finally we can install SDStore’s requirements.

pip install -r sd_store/requirements.txt

Now, update the database.

python manage.py migrate

Test the project by calling:

python manage.py runserver

Open your browser and head over to http://localhost:8000/admin/ and login using your super user account we created earlier. You should see two panels on the left. One should be called SD_STORE.

SDStore Django Admin Example

What next?

Now you have an SD Store project up and running head to the documentation to learn how to send and receive data.