Skip to content

Instantly share code, notes, and snippets.

@hako
Last active December 15, 2021 14:29
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save hako/f8944cfa7b8fb8115f6d to your computer and use it in GitHub Desktop.
Save hako/f8944cfa7b8fb8115f6d to your computer and use it in GitHub Desktop.
Installing Sirius on Mac / Linux / Raspberry Pi

Installing Sirius on Mac / Linux / Raspberry Pi

Tested working on:

  • Raspberry Pi 1 Model B+ (Using Docker hypriot/rpi-python) (debian/wheezy)
  • Raspberry Pi 2 Model B (with virtualenv)
  • Ubuntu Linux x64 (with virtualenv)
  • Ubuntu Linux x64 (Using Docker)
  • OS X Yosemite (with virtualenv)

Not tested on:

  • Raspberry Pi 1 Model B (with virtualenv or Docker)
  • Raspberry Pi 3 Model B (with virtualenv or Docker)
  • Windows 10 (with Linux Subsystem)
  • Windows (with VirtualBox)
  • OS X El Capitan

This guide is regularly updated and tested with 0 dead page links. (excluding localhost links)

Quickstarts:

You have three options:

Once the server is up and running, Skip to Step 5 to connect the server to the printer.

Raspberry Pi Quickstart

Using a Raspberry Pi? If you would like to install sirius quickly on your Pi, @anneris has put together a prebuilt Raspberry Pi image and other sirius installation options.

Docker Quickstart

If you are familiar with Docker, I have built a sirius Docker image:

hakobyte/sirius (~296.1 MB)

Run docker run -t -p 5000:5000 hakobyte/sirius /usr/bin/honcho start to use that image and skip to Step 5.

If you prefer to go down the manual route, continue to follow the guide below.

DIY Tutorial

Prequisites:

postgresql foreman/honcho phantomjs libfreetype6-dev fontconfig libgstreamer0.10-dev python-dev

On Linux/Raspberry Pi, run [sudo] apt-get update before installing the prequisites.

This guide assumes you have either python, pip or ruby installed.

This guide also assumes that wget and git are installed.

--

Installing postgresql

Linux: [sudo] apt-get install libpq-dev

OS X: brew install postgresql

--

Installing foreman/honcho

Foreman and Honcho manage Procfile-based applications and sirius is one of them. You can install either foreman or honcho. It doesn't matter which one you install, both do the same thing.

foreman (Ruby) [sudo] gem install foreman

If you want to install honcho instead, you can consider installing it before or after installing virtualenv & virtualenvwrapper in Step 1.

honcho (Python) [sudo] pip install honcho

--

Installing phantomjs

Dependencies (Linux):

[sudo] apt-get install libfreetype6-dev fontconfig libgstreamer0.10-dev python-dev

This guide uses phantomjs 1.9.8

OS X (With brew): brew install phantomjs

All platforms (x86-x64): ariya/phantomjs/downloads

Raspberry Pi & other ARM boards: (From piksel/phantomjs-raspberrypi)

phantomjs 1.9.8 (ARM binary)

You can use these scripts for your platform below:

Linux (x64)

wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2 \
    && tar jxf phantomjs-1.9.8-linux-x86_64.tar.bz2 \
    && sudo mv phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs

Linux (x86)

wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.tar.bz2 \
    && tar jxf phantomjs-1.9.8-linux-i686.tar.bz2 \
    && sudo mv phantomjs-1.9.8-linux-i686/bin/phantomjs /usr/local/bin/phantomjs

Raspberry Pi (ARM)

wget -O phantomjs https://git.io/vzA6L \
&& chmod +x phantomjs \
&& sudo mv phantomjs  /usr/local/bin/phantomjs

--

Step 1

Install virtualenv & virtualenvwrapper. (Optional)

[sudo] pip install virtualenv virtualenvwrapper
export WORKON_HOME=~/Envs
echo "export WORKON_HOME=~/Envs" >> ~/.bashrc
mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv lpenv
workon lpenv

If you use a different shell eg. zsh, change line 3 from ~/.bashrc to ~/.zshrc

Step 2

Download the sirius source code.

git clone https://github.com/genmon/sirius.git
cd  sirius

Step 3

Install python requirements.

Linux:

[sudo] pip install -r requirements.txt

Mac:

// gevent fails to build
[sudo] CFLAGS='-std=c99' pip install -r requirements.txt

(Note: If you get SSLv3 errors like NameError: name 'PROTOCOL_SSLv3' is not defined, upgrade gevent)

[sudo] pip install gevent==1.0.2

Step 4

Migrate the database.

./manage.py db upgrade

and start the server.

foreman (Ruby)

foreman start

Or

honcho (Python)

honcho start

What you should see:

web.1  | [2016-01-19 06:17:55 +0000] [42169] [INFO] Starting gunicorn 19.1.1
web.1  | [2016-01-19 06:17:55 +0000] [42169] [INFO] Listening at: http://0.0.0.0:5000 (42169)
web.1  | [2016-01-19 06:17:55 +0000] [42169] [INFO] Using worker: flask_sockets.worker
web.1  | [2016-01-19 06:17:55 +0000] [42172] [INFO] Booting worker with pid: 42172
web.1  | --------------------------------------------------------------------------------
web.1  | DEBUG in webapp [<path>]:
web.1  | Creating app.
web.1  | --------------------------------------------------------------------------------
web.1  | DEBUG:sirius.web.webapp:Creating app.

Step 5

Step 5 requires that your bridge is updated to connect to custom little printer servers. Connect your bridge and navigate to this URL.

http://<bridge ip>:81/configure

To find your BERG Cloud bridge IP address type inside the terminal:

arp -a | grep "40:d8:55"

This command should find your BERG Cloud bridge Mac address and IP on the LAN.

You should see a dialog box requesting a username and password.

username: berg

password: hereandthere

Step 6

Change Server URL to point to your sirius server you perfomed foreman start on.

Getting the IP address

Mac: Go to (System Prefrences -> Network) and you should see Status. Copy the IP address.

Linux: Run hostname -I to get your IP address.

Copy & Paste the IP address into the Server URL with the port number as 5000 and hit submit.

Like so: http://<sirius ip>:5000/

Your bridge should restart.

Step 7

Reset your Little Printer by using a paperclip and pushing the button inside the tiny hole in the Printer.

The Little Printer should be reset at this point and you can print out a claim code once the Printer's LED is white.

Step 8

Navigate to http://<sirius ip>:5000/ and sign in into Twitter.

Once signed in hit claim Printer and enter your claim code.

Step 9

If you've reached this point the claim code should have worked and now you're ready to use sirius.

Your twitter users you follow, can also now send messages to your printer!

If you want to send a message to your Little Printer, click "send message". Enter your message and hit "Print Now."

\o/ Happy Printing! \o/

Credits:

@geocontrol
Copy link

Hi,

Just a quick note, went through this on a raspberry pi (so its behind my firewall, so need to look at getting messages from others onto it later) but this worked a treat! I think my issue from before was not having phantomjs installed correctly.

Thanks for doing this!

Mark

@johndietrich
Copy link

For those who've done this on a Raspberry Pi, I'd appreciate any help as to why I can't quite get it working. I'm using Raspbian Jessie installed via NOOBS, so I had to make a few adjustments (like requiring gevent 1.0.2 instead of 1.0.1 because it was throwing an SSL_V3 error when starting foreman). In any case, I finally got everything to "appear" to work, but on startup I get this:


(lpenv) pi@raspberrypi ~/sirius $ foreman start
04:24:00 web.1 | started with pid 1281
04:24:03 web.1 | [2016-01-21 04:24:03 +0000] [1281] [INFO] Starting gunicorn 19.1.1
04:24:03 web.1 | [2016-01-21 04:24:03 +0000] [1281] [INFO] Listening at: http://0.0.0.0:5000 (1281)
04:24:03 web.1 | [2016-01-21 04:24:03 +0000] [1281] [INFO] Using worker: flask_sockets.worker
04:24:03 web.1 | [2016-01-21 04:24:03 +0000] [1287] [INFO] Booting worker with pid: 1287
04:24:09 web.1 | --------------------------------------------------------------------------------
04:24:09 web.1 | DEBUG in webapp [/home/pi/sirius/sirius/web/webapp.py:65]:
04:24:09 web.1 | Creating app.
04:24:09 web.1 | --------------------------------------------------------------------------------
04:24:09 web.1 | DEBUG:sirius.web.webapp:Creating app.
04:24:09 web.1 | SystemError: NULL result without error in PyObject_Call
04:24:09 web.1 | <callback at 0xb5a6bd90 stopped> failed with SystemError
04:24:09 web.1 |
04:24:09 web.1 | [2016-01-21 04:24:09 +0000] [1291] [INFO] Booting worker with pid: 1291
04:24:15 web.1 | --------------------------------------------------------------------------------
04:24:15 web.1 | DEBUG in webapp [/home/pi/sirius/sirius/web/webapp.py:65]:
04:24:15 web.1 | Creating app.
04:24:16 web.1 | --------------------------------------------------------------------------------
04:24:16 web.1 | DEBUG:sirius.web.webapp:Creating app.
04:24:16 web.1 | SystemError: NULL result without error in PyObject_Call
04:24:16 web.1 | <callback at 0xb5a6bd90 stopped> failed with SystemError
04:24:16 web.1 |
04:24:16 web.1 | [2016-01-21 04:24:16 +0000] [1340] [INFO] Booting worker with pid: 1340
04:24:22 web.1 | --------------------------------------------------------------------------------
04:24:22 web.1 | DEBUG in webapp [/home/pi/sirius/sirius/web/webapp.py:65]:
04:24:22 web.1 | Creating app.
04:24:22 web.1 | --------------------------------------------------------------------------------
04:24:22 web.1 | DEBUG:sirius.web.webapp:Creating app.
04:24:22 web.1 | SystemError: NULL result without error in PyObject_Call
04:24:22 web.1 | <callback at 0xb5a6bd90 stopped> failed with SystemError


And it wants to keep booting "worker" ad nauseam with a new process ID each time -- any clue what "NULL result without error in PyObject_Call" is trying to tell me? :)

@bentimms
Copy link

I get the same issue as johndietrich: "SystemError: NULL result without error in PyObject_Call"

Any hints or tips greatly appreciated!

@hako
Copy link
Author

hako commented Jan 30, 2016

@bentimms @johndietrich I was able to reproduce this issue on a fresh installation of Raspbian Jessie, (Raspberry Pi Model B+)

I'm thinking it could be a RAM issue. Could I ask what Raspberry Pi Models you are using? I got this working on a Raspberry Pi 2 with no issues.

@felippenardi
Copy link

Is there a way to print images already?

@hako
Copy link
Author

hako commented Jul 23, 2016

@felippenardi AFAIK yes, I've printed an image using sirius before, But now my printer is bricked and I cannot print again.

@digitalsalat
Copy link

unfortunately that here is way beyond my tech level... and now I'm stuck. I got sirius on my pi, got foreman running, got to the website on my pi and the printer config points to the pi. Now when I try to login to twitter I get forwarded to the twitter auth site where I can auth the script but then forwarding back to the pi ends up with "Internal Server Error". Moving back to the sirius site on the pi still only gives the option to sign in with twitter :-/

any ideas?

@digitalsalat
Copy link

This is what's happening on the pi

OperationalError: (OperationalError) no such table: twitter_o_auth u'SELECT twitter_o_auth.id AS twitter_o_auth_id, twitter_o_auth.created AS twitter_o_auth_created, twitter_o_auth.user_id AS twitter_o_auth_user_id, twitter_o_auth.screen_name AS twitter_o_auth_screen_name, twitter_o_auth.token AS twitter_o_auth_token, twitter_o_auth.token_secret AS twitter_o_auth_token_secret, twitter_o_auth.last_friend_refresh AS twitter_o_auth_last_friend_refresh, twitter_o_auth.friends AS twitter_o_auth_friends \nFROM twitter_o_auth \nWHERE twitter_o_auth.screen_name = ?\n LIMIT ? OFFSET ?' (u'digitalsalat', 1, 0)

@olliez0r
Copy link

@digitalsalat, through sheer persistence, trawling stack exchange and just blindly poking around I've managed to sort this error! From the Sirius path run "python manage.py db upgrade" and it'll actually build the database... mine was just sat empty before.

@digitalsalat
Copy link

@olliez0r : will try that tonite, thank you! Blindly poking is my way to go, too 👍

@pablonoel
Copy link

BTW @digitalsalat that solved it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment