Skip to content

Commit

Permalink
Merge pull request #280 from kalliope-project/dev
Browse files Browse the repository at this point in the history
Kalliope v0.4.4
  • Loading branch information
LaMonF committed May 21, 2017
2 parents 4c6586b + f42b62d commit 622d5ee
Show file tree
Hide file tree
Showing 171 changed files with 5,505 additions and 1,923 deletions.
25 changes: 23 additions & 2 deletions .travis.yml
@@ -1,8 +1,16 @@
language: python

services:
- docker

python:
- "2.7"
- "3.4"

# command to install dependencies
before_install:
- docker build --force-rm=true --build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} --build-arg TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} --build-arg TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} --build-arg TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} -t kalliope-ubuntu1604 -f docker/ubuntu_16_04.dockerfile .
- docker build --force-rm=true --build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} --build-arg TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} --build-arg TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} --build-arg TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} -t kalliope-debian8 -f docker/debian8.dockerfile .
- sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse"
- sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse"
- sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse"
Expand All @@ -11,6 +19,19 @@ before_install:
- sudo apt-get install libstdc++6
- wget https://bootstrap.pypa.io/get-pip.py
- sudo python get-pip.py
install: "pip install -r install/files/python_requirements.txt"

install:
- pip install -r install/files/python_requirements.txt
- pip install python2-pythondialog || pip install pythondialog
- pip install coveralls

# command to run tests
script: pytest
script:
# - pytest
- docker run -it --rm kalliope-ubuntu1604
- docker run -it --rm kalliope-debian8
- coverage run --source=kalliope -m unittest discover

after_success:
coveralls

17 changes: 17 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,20 @@
v0.4.4 / 2017-05-20
===================
- Fix: Uppercase in order/parameters/global variables are now handled correctly
- Fix: usage of integer in neuron parameters
- Fix: encoding with special character
- Refactor main controller. Use a LIFO to allow full usage of kalliope via API (even with neurotransmitter)
- Add a systemd script to start kalliope automatically
- docker testing
- python 3 support 3.4, 3.5, 3.6
- Increase testing code coverage
- Fix: Raspberry performance. CPU usage from 120% to 15%
- Input value refactoring. "args" parameter replaced by jinja templating
- Review TTS overriding config in neuron declaration
- Fix: accapela TTS
- LED and mute button support for Raspberry Pi
- Player modularity

v0.4.3 / 2017-03-11
===================
- Update Documentation
Expand Down
28 changes: 28 additions & 0 deletions Docs/installation.md
Expand Up @@ -95,5 +95,33 @@ Those repositories provide you a basic structure to start playing with kalliope.
- [English starter config](https://github.com/kalliope-project/kalliope_starter_en)
- [German starter config](https://github.com/kalliope-project/kalliope_starter_de)


## Start Kalliope automatically after a reboot

If you want to start Kalliope automatically Place the script bellow in `/etc/systemd/system/kalliope.service`.
Update the path to your folder where you've placed your `brain.yml` and `settings.yml`.
```bash
[Unit]
Description=Kalliope

[Service]
WorkingDirectory=/path/to/kalliope_brain_folder

Environment='STDOUT=/var/log/kalliope.log'
Environment='STDERR=/var/log/kalliope.err.log'
ExecStart=/bin/bash -c "/usr/local/bin/kalliope start > ${STDOUT} 2> ${STDERR}"
User=%i

[Install]
WantedBy=multi-user.target
```

Then, reload systemctl, start the service and enable it at startup
```bash
sudo systemctl daemon-reload
sudo systemctl start kalliope
sudo systemctl enable kalliope
```

## Next:
If everything is ok, you can start playing with Kalliope. First, take a look to the [default settings](settings.md).
260 changes: 260 additions & 0 deletions Docs/installation/create_raspbian_image.md
@@ -0,0 +1,260 @@
# Create a Raspbian image with already installed Kalliope

This documentation aims at explaining how to creta a Raspbian image with pre installed Kalliope.

Install a fresh [image of Raspbian](http://downloads.raspberrypi.org/raspbian/images/) as usual on your raspberry Pi.
Once deployed, follow manual steps bellow.

>**Note:** From here I suppose that the Rpi has received a valid IP from your LAN DHCP server and can access to the internet.
## Prepare the image
Login to your Rpi.

Enable SSH
```bash
sudo systemctl enable ssh
sudo systemctl start ssh
```

You now have a SSH connection, you can connect remotely to your Pi to perform next steps from a console.

>**Note:** The SSH server is listening on the default SSH port with the default Rasbpian credentials. This can be a security issue.
It is recommended to check that the Rpi is not directly accessible from the internet.

Install Kalliope from the script
```bash
curl -s https://raw.githubusercontent.com/kalliope-project/kalliope/master/install/rpi_install_kalliope.sh | bash
```

If you want to install a particular branch you can specify it with an argument following the syntax bellow
```
curl -s https://raw.githubusercontent.com/kalliope-project/kalliope/master/install/rpi_install_kalliope.sh | bash -s <branch_name>
```

E.g
```bash
curl -s https://raw.githubusercontent.com/kalliope-project/kalliope/master/install/rpi_install_kalliope.sh | bash -s dev
```

Check Kalliope is installed
```bash
kalliope --version
```

Cleanup installation files
```bash
rm -rf get-pip.py
sudo rm -rf kalliope
```

Clone some starter kit
```bash
git clone https://github.com/kalliope-project/kalliope_starter_fr.git
git clone https://github.com/kalliope-project/kalliope_starter_en.git
git clone https://github.com/kalliope-project/kalliope_starter_de.git
```

Change the hostname
```bash
sudo hostnamectl set-hostname kalliope
sudo sed -i 's/raspberrypi/kalliope/g' /etc/hosts
```

Clear the command line history
```bash
history -c
```

Shutdown the Rpi
```bash
sudo shutdown -h now
```

## Create the image

Next commands have been tested on Ubuntu 16.04.

In the next part we create an image an shrink it in order to take less storage space.
>**Note:** Raspbian operating system comes with a tool to resize the filesystem to the largest size the SD card will support (sudo raspi-config, then select Expend Filesystem). You wont lose space by shrinking the image because you can expand it back again.
>**Note:** Be sure of what you doing in next steps. Writing disk image on the wrong disk will destroy all your computer data.
Remove the SD card from your Rpi and connect it into a Linux distrib via an external USB card reader.

Check where the card is mounted
```bash
df -h
```

The output should looks like this
```bash
df -h
Filesystem Size Used Avail Use% Mounted on
--- TRUNCKATED ---
/dev/sdb2 15G 1.3G 13G 10% /media/nico/f2100b2f-ed84-4647-b5ae-089280112716
/dev/sdb1 41M 21M 21M 51% /media/nico/boot
```

The SD card is on **/dev/sdb device**. It has two partition, **/dev/sdb1** and **/dev/sdb2**.

>**Note:** Your system might mount the card somewhere else depending on the number of disk you already have like /dev/sdc or /dev/sde.
Note down the path where your SD is.

Unmount the two partitions. Keep the SD card in the reader and connected to the system.
```bash
sudo umount /dev/sdb1 /dev/sdb2
```

Make the image with **dcfldd**. This program is a replacement for the old dd disk utility program that show the progression of a copy.

Install the tool
```bash
sudo apt-get install dcfldd
```

Create the image following this syntax.
```
sudo dcfldd if=<my_sd_card_disk_path> of=<target_path>/kalliope.img
```

E.g
```bash
sudo dcfldd if=/dev/sdb of=kalliope.img
```
>**Note:** Be sure you have enough space available in the target path
It will take a couple minutes to create the image depending of the size of your SD card.

Once it's done, give the ownership back to your current user. (the image belong to root as we created it with sudo)
```bash
sudo chown ${USER}:${USER} kalliope.img
```

Now we have a file that can already be used to instantiate a Rpi. But the file is big as the SD card itself.
To reduce the size of the image we need `gparted`. Install it
```bash
sudo apt-get install gparted
```

Gparted is only able to edit physical device, so we need to create a virtual device from the image before using it.
As we saw when we have identified our disk, Raspbian has two partitions. The fist one, boot, is already tiny and does not need to be shrank.
The second partition is where everything is stored. It contains a lot of free space.

Show partition info from the image
```bash
sudo fdisk -l kalliope.img
```

The output should looks like this
```
Device Boot Start End Sectors Size Id Type
kalliope.img1 8192 92159 83968 41M c W95 FAT32 (LBA)
kalliope.img2 92160 31116287 31024128 14.8G 83 Linux
```

Export the START sector of the second partition. The variable will be used in next commands.
```bash
export START=92160
```

Check the env variable is set correctly
```bash
echo ${START}
```

Create the virtual drive with only the second patition
```bash
sudo losetup /dev/loop0 kalliope.img -o $((START*512))
```

Now read the loopback device with gparted
```bash
sudo gparted /dev/loop0
```

Gparted will show you the state of the partition. Click the `/dev/loop0` partition and select **Resize/Move** from the menu.
change the value of "New Size" so that it is slighty abose the "Minimum Size".
Note down the new size! In this example the new size is **2000 MB**.
Then apply the resizing and exit gparted.

Remove the loopback device and create a new one with the whole image this time.
```bash
sudo losetup -d /dev/loop0
sudo losetup /dev/loop0 kalliope.img
```

Now, we use **fdisk** to edit the partition table in order to resize it to the new size.
```bash
sudo fdisk /dev/loop0
```

You should now see the **fdisk** prompt.
- Enter **d 2** to delete the table entry for the second partition
- Enter n p 2 to create a new second partition entry
- Enter the START sector number that you used earlier.
- Enter `+NEWSIZE` as the new size. Don't forget the "+" at the start. For example `+2000M`
- Enter w to write the new partition


Output example
```
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-31116287, default 2048): 92160
Last sector, +sectors or +size{K,M,G,T,P} (92160-31116287, default 31116287): +2000M
Created a new partition 2 of type 'Linux' and of size 2 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
```
Let's take a look to the partition table again
```
sudo fdisk -l /dev/loop0
Device Boot Start End Sectors Size Id Type
/dev/loop0p1 8192 92159 83968 41M c W95 FAT32 (LBA)
/dev/loop0p2 92160 4188159 4096000 2G 83 Linux
```

Note down the ED sector of the second partition
```bash
export END=4188159
```

Destroy the loopback
```bash
sudo losetup -d /dev/loop0
```

Now, trim the file to the new length.
```
truncate -s $(((END+1)*512)) kalliope.img
```

Check the new size of the image
```bash
du -hs kalliope.img
2.0G kalliope.img
```

You can now compress it to reduce a little more the size
```bash
zip kalliope.img.zip kalliope.img
```

Final size
```bash
du -hs kalliope.img.zip
727M kalliope.img.zip
```
2 changes: 1 addition & 1 deletion Docs/installation/debian_jessie.md
Expand Up @@ -12,7 +12,7 @@ Install some required system libraries and softwares:

```bash
sudo apt-get update
sudo apt-get install git python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog libffi-dev libffi-dev libssl-dev portaudio19-dev build-essential libssl-dev libffi-dev sox libatlas3-base mplayer
sudo apt-get install git python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog libffi-dev libffi-dev libssl-dev portaudio19-dev build-essential libssl-dev libffi-dev sox libatlas3-base mplayer libav-tools
```

Let's install the last release of python-pip
Expand Down
5 changes: 3 additions & 2 deletions Docs/installation/raspbian_jessie.md
Expand Up @@ -9,14 +9,15 @@ Download the last image [from the release page](https://github.com/kalliope-proj

Once installed, use the `raspi-config` command to expend the file system and fill the whole available space on your SD card.
The SSH server is already active. You only need to get the ip of your Rpi via the command `ip a` and then connect via your favourite SSH client.
We placed in `/home/pi` the two starter config we made for [French](https://github.com/kalliope-project/kalliope_starter_fr) and [English](https://github.com/kalliope-project/kalliope_starter_en).
We placed in `/home/pi` the two starter config we made for [French](https://github.com/kalliope-project/kalliope_starter_fr), [English](https://github.com/kalliope-project/kalliope_starter_en) and [German](https://github.com/kalliope-project/kalliope_starter_de).

## Manual installation

Supported Raspbian images:
[raspbian-2016-09-28](http://downloads.raspberrypi.org/raspbian/images/raspbian-2016-09-28/)
[raspbian-2016-11-29](http://downloads.raspberrypi.org/raspbian/images/raspbian-2016-11-29/)
[raspbian-2017-01-10](http://downloads.raspberrypi.org/raspbian/images/raspbian-2017-01-10/)
[raspbian-2017-04-10](http://downloads.raspberrypi.org/raspbian/images/raspbian-2017-04-10/)

> **Note:** We recommend to use a **lite** installation of Raspbian without any graphical interface for a better experience.
Expand All @@ -28,7 +29,7 @@ Install some required system libraries and software:

```bash
sudo apt-get update
sudo apt-get install git python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog libffi-dev libffi-dev libssl-dev portaudio19-dev build-essential libssl-dev libffi-dev sox libatlas3-base mplayer libyaml-dev libpython2.7-dev
sudo apt-get install git python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog libffi-dev libffi-dev libssl-dev portaudio19-dev build-essential libssl-dev libffi-dev sox libatlas3-base mplayer libyaml-dev libpython2.7-dev libav-tools
```

Let's install the last release of python-pip
Expand Down
2 changes: 1 addition & 1 deletion Docs/installation/ubuntu_14.04.md
Expand Up @@ -6,7 +6,7 @@ Install some required system libraries and softwares:

```bash
sudo apt-get update
sudo apt-get install git python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog libffi-dev libffi-dev libssl-dev libjack0 libjack-dev portaudio19-dev build-essential libssl-dev libffi-dev sox libatlas3-base mplayer
sudo apt-get install git python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog libffi-dev libffi-dev libssl-dev libjack0 libjack-dev portaudio19-dev build-essential libssl-dev libffi-dev sox libatlas3-base mplayer libav-tools
```

Let's install the last release of python-pip
Expand Down

0 comments on commit 622d5ee

Please sign in to comment.