Skip to content
Kalle Johansson edited this page May 27, 2020 · 14 revisions

Welcome to the Mycroft wiki!

Configuration

To set up the project, you will have to install Django and Django REST. To do this you will probably want to create a Python Virtual Environment.

Prerequisites

The following tools are expected to be installed on the hosting machine.

If building on Windows, makes sure to update the PATH Environment Variable. This is usually an option in the installer.

  • Python 3.8.1
  • Node.js

Note: If you can't run python from the terminal and you have already added the path. Move the path for python in Environment Variable, to the top. This will prioritize this path over the ones below.

To make sure everything is installed, run:

  • python --version
  • npm -v
  • node -v

Create Virtual Environment

Run python -m venv venv in the root-folder of the project to create a folder called venv.

Activate Virtual Environment

Still in the root folder, to activate the virtual environement:

  • run source venv/bin/activate on Linux
  • run "venv/Scripts/activate.bat" on Windows cmd
  • run ./venv/Scripts/activate.ps1 on Windows Powershell

Deactivate Virtual Environment

To deactivate the virtual environment, run deactivate.

Install Tools

First, activate the virtual environment, then run pip install -r requirements.txt.

You are now ready to roll!

Development

This chapter describes where code should be written.

Frontend

Frontend code should be written in the frontend/src.

Backend

Backend interfaces should be implemented in different Django apps, not frontend.

Operations

There are several scripts in the root-folder of the project. This chapter describes what they do. To run these operations you must first activate the virtual environment as described above.

Note: To run scripts in Windows Powershell you write: ./filename

run

This script starts the Django server.

pack

This script packs the frontend using webpack. This process combines all dependencies and compiles them to a single file. Whenever the frontend has been updated, this scripts must be run. Note that there is no need to stop the server whilst doing this.

migrate

This script migrates all current Django-models into actual databases. This effectively runs makemigrations and migrate. See documentation.

setentryfolder <absolute path>

This script sets the entry folder which means that it loads the folder, all its subfolders and relevant files to the database so they can be used in the application. The script takes the absolute path to entry folder as an argument.

genfakemetadata.py [rootDir] [latitude] [longitude] [radius] [minStartTime] [maxEndTime]

This script creates fake metadata for all clips in the given folder.

Example of usage:

python genfakemetadata.py "C:\Users\name\Desktop\my_videos" "58.4106639" "15.6198244" "1000" "2020-05-27 12:00:00" "2020-05-28 02:00:00"