Skip to content

Commit c0b8514

Browse files
author
Joseph Atkins-Turkish
committed
Merge branch 'master' into feature/autofocus
Conflicts: ide/static/ide/js/resources.js ide/templates/ide/project/resource.html
2 parents 204360e + 93fcb03 commit c0b8514

39 files changed

+1677
-481
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ src/
1111
.cache/
1212
.env/
1313
.idea/
14+
bower_components

Dockerfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
FROM python:2.7
2+
MAINTAINER Katharine Berry <[email protected]>
3+
4+
ENV NPM_CONFIG_LOGLEVEL=info NODE_VERSION=4.2.3 DJANGO_VERSION=1.6
5+
6+
# Node stuff.
7+
8+
# gpg keys listed at https://github.com/nodejs/node
9+
RUN set -ex \
10+
&& for key in \
11+
9554F04D7259F04124DE6B476D5A82AC7E37093B \
12+
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
13+
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
14+
FD3A5288F042B6850C66B31F09FE44734EB7990E \
15+
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
16+
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
17+
; do \
18+
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
19+
done
20+
21+
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \
22+
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
23+
&& gpg --verify SHASUMS256.txt.asc \
24+
&& grep " node-v$NODE_VERSION-linux-x64.tar.gz\$" SHASUMS256.txt.asc | sha256sum -c - \
25+
&& tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 \
26+
&& rm "node-v$NODE_VERSION-linux-x64.tar.gz" SHASUMS256.txt.asc
27+
28+
# Django stuff
29+
30+
RUN apt-get update && apt-get install -y \
31+
gettext \
32+
postgresql-client libpq-dev \
33+
--no-install-recommends && rm -rf /var/lib/apt/lists/*
34+
35+
RUN pip install psycopg2 django=="$DJANGO_VERSION"
36+
37+
EXPOSE 8000
38+
39+
# CloudPebble stuff
40+
RUN npm install -g bower && echo '{"allow_root": true}' > ~/.bowerrc
41+
42+
# Grab the toolchain
43+
RUN curl -o /tmp/arm-cs-tools.tar https://cloudpebble-vagrant.s3.amazonaws.com/arm-cs-tools-stripped.tar && \
44+
tar -xf /tmp/arm-cs-tools.tar -C / && rm /tmp/arm-cs-tools.tar
45+
46+
ADD requirements.txt /tmp/requirements.txt
47+
RUN pip install --no-cache-dir -r /tmp/requirements.txt
48+
49+
ENV SDK_TWO_VERSION=2.9
50+
51+
# Install SDK 2
52+
RUN mkdir /sdk2 && \
53+
curl -L "https://s3.amazonaws.com/assets.getpebble.com/sdk3/sdk-core/sdk-core-${SDK_TWO_VERSION}.tar.bz2" | \
54+
tar --strip-components=1 -xj -C /sdk2
55+
56+
ENV SDK_THREE_VERSION=3.8.1
57+
58+
# Install SDK 3
59+
RUN mkdir /sdk3 && \
60+
curl -L "https://s3.amazonaws.com/assets.getpebble.com/sdk3/release/sdk-core-${SDK_THREE_VERSION}.tar.bz2" | \
61+
tar --strip-components=1 -xj -C /sdk3
62+
63+
COPY . /code
64+
WORKDIR /code
65+
66+
# Bower is awful.
67+
RUN rm -rf bower_components && cd /tmp && python /code/manage.py bower install && mv bower_components /code/
68+
69+
RUN python manage.py compilemessages
70+
71+
CMD ["sh", "docker_start.sh"]

README.md

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,12 @@ support.
77
Getting Started
88
---------------
99

10-
The easiest way to get an instance of CloudPebble running is to use [Vagrant][].
11-
The supplied virtual machine assumes [VirtualBox][], so you'll want to have that installed too.
12-
You will also need ports 8000 and 8001 to be available on your machine.
10+
The easiest way to get a fully-functional copy of CloudPebble is using Docker and Docker Compose. Instructions can
11+
be found in the [https://github.com/pebble/cloudpebble-composed](cloudpebble-composed) repo.
1312

14-
With those set up, just clone the repo and run `vagrant up`:
1513

16-
host:~/cloudpebble$ vagrant up
17-
18-
After some waiting, you should have a functional instance running at [http://localhost:8000](http://localhost:8000).
19-
20-
In general, you can then stop it with `vagrant halt`, start it with `vagrant up`, and restart it with `vagrant reload`.
21-
If you need to recreate the thing, you can use `vagrant destroy` and `vagrant up` again. No persistent data is stored
22-
in the VM, so doing this is safe.
23-
24-
The server will be running in debug mode with autoreload enabled. However, the worker will not autoreload, so if you
25-
make changes that the worker should pick up on, you must restart it manually:
26-
27-
28-
host:~/cloudpebble$ vagrant ssh
29-
vagrant@precise32:~$ sudo restart cloudpebble-celery
30-
31-
32-
To locally override the configuration, create a file at `cloudpebble/settings_local.py` and set the appropriate values
33-
there.
14+
To locally override the configuration, you can create a file at `cloudpebble/settings_local.py` and set the
15+
appropriate values there. Setting environment variables also works.
3416

3517
Note that you won't be able to set up integration with certain Pebble systems (e.g. Pebble SSO). This shouldn't usually
3618
matter; whenever these are used, an alternative route is provided and should be invoked in its absence.
@@ -44,6 +26,4 @@ logical sense. Please avoid commits that fix typos in prior commits.
4426
If a change is a significant amount of work, it would probably be worth creating an issue to discuss it first. Pull
4527
requests are not automatically accepted (though they usually are).
4628

47-
[Vagrant]: http://www.vagrantup.com
48-
[VirtualBox]: http://virtualbox.org
4929
[support]: mailto:[email protected]

app.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@
3232
"required": true
3333
},
3434
"QEMU_URLS": "https://qemu-us1.cloudpebble.net/",
35-
"SDK2_PEBBLE_TOOL": "/app/sdk2/bin/pebble",
36-
"SDK3_PEBBLE_TOOL": "/app/sdk3/bin/pebble",
35+
"SDK2_PEBBLE_WAF": "/app/sdk2/pebble/waf",
36+
"SDK3_PEBBLE_WAF": "/app/sdk3/pebble/waf",
3737
"TYPOGRAPHY_CSS": "//cloud.typography.com/7515512/745724/css/fonts.css",
3838
"WEB_CONCURRENCY": "2",
3939
"YCM_URLS": "https://ycm1.cloudpebble.net/"
4040
},
4141
"addons": [
42-
"cloudamqp:lemur",
4342
"papertrail:choklad",
4443
"heroku-postgresql:hobby-dev",
4544
"heroku-redis:hobby-dev"

bin/post_compile

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,26 @@ set -e
66
# Make sure we have the SDK in place.
77

88
echo "Downloading SDK 2"
9-
curl -o /tmp/pebblesdk2.tar.gz -L https://sdk.getpebble.com/download/2.8.1?source=cloudpebble
9+
curl -o /tmp/pebblesdk2.tar.gz -L https://s3.amazonaws.com/assets.getpebble.com/sdk3/sdk-core/sdk-core-2.9.tar.bz2
1010

1111
echo "Downloading SDK 3"
12-
curl -o /tmp/pebblesdk3.tar.gz -L https://sdk.getpebble.com/download/3.7?source=cloudpebble
12+
curl -o /tmp/pebblesdk3.tar.gz -L https://s3.amazonaws.com/assets.getpebble.com/sdk3/release/sdk-core-3.8.1.tar.bz2
1313

1414
echo "Downloading the toolchain"
1515
curl -o /tmp/arm-cs-tools.tar https://cloudpebble-vagrant.s3.amazonaws.com/arm-cs-tools-stripped.tar
16+
tar -xf /tmp/arm-cs-tools.tar
1617

17-
echo "Extracting SDK 2"
18-
tar -xf /tmp/pebblesdk2.tar.gz
19-
mv PebbleSDK-2.8.1 sdk2
18+
19+
mkdir sdk2
2020
pushd sdk2
21-
echo "Extracting the toolchain"
22-
tar -xf /tmp/arm-cs-tools.tar
23-
echo "Preparing virtualenv"
24-
virtualenv .env
25-
# Instead of actually installing the requirements, we instead just use the global ones, which are a superset
26-
# of the ones here.
27-
# source .env/bin/activate
28-
# pip install -r requirements.txt
29-
# deactivate
21+
echo "Extracting SDK 2"
22+
tar --strip 1 -xf /tmp/pebblesdk2.tar.gz
3023
popd
3124

3225
mkdir sdk3
3326
pushd sdk3
3427
echo "Extracting SDK 3"
3528
tar --strip 1 -xf /tmp/pebblesdk3.tar.gz
36-
echo "Extracting the toolchain"
37-
tar -xf /tmp/arm-cs-tools.tar
38-
echo "Preparing virtualenv"
39-
virtualenv .env
4029
popd
4130

4231
touch NO_TRACKING

bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ popd
6363
# Obtain SDK3.
6464
sudo -u vagrant mkdir sdk3
6565
pushd sdk3
66-
wget --progress=bar:force -O sdk.tar.gz https://sdk.getpebble.com/download/3.7?source=cloudpebble
66+
wget --progress=bar:force -O sdk.tar.gz https://s3.amazonaws.com/assets.getpebble.com/sdk3/release/sdk-core-3.8.1.tar.bz2
6767
sudo -u vagrant tar --strip 1 -xzf sdk.tar.gz
6868
rm sdk.tar.gz
6969
sudo -u vagrant ln -s ~/arm-cs-tools arm-cs-tools

cloudpebble/settings.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Django settings for cloudpebble project.
33

44
import os
5+
import socket
56
import dj_database_url
67
_environ = os.environ
78

@@ -21,13 +22,11 @@
2122
if 'DATABASE_URL' not in _environ:
2223
DATABASES = {
2324
'default': {
24-
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
25-
'NAME': os.getcwd() + '/dev.db', # Or path to database file if using sqlite3.
26-
# The following settings are not used with sqlite3:
27-
'USER': '',
28-
'PASSWORD': '',
29-
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
30-
'PORT': '', # Set to empty string for default.
25+
'ENGINE': 'django.db.backends.postgresql_psycopg2',
26+
'NAME': 'postgres',
27+
'USER': 'postgres',
28+
'HOST': 'postgres',
29+
'PORT': 5432,
3130
}
3231
}
3332
else:
@@ -191,6 +190,12 @@
191190
SOCIAL_AUTH_PEBBLE_ROOT_URL = _environ.get('PEBBLE_AUTH_URL', None)
192191
PEBBLE_AUTH_ADMIN_TOKEN = _environ.get('PEBBLE_AUTH_ADMIN_TOKEN', None)
193192

193+
SHOULD_BE_SECURE = _environ.get('EXPECT_SSL', '') != ''
194+
195+
SESSION_COOKIE_HTTPONLY = True
196+
SESSION_COOKIE_SECURE = SHOULD_BE_SECURE
197+
CSRF_COOKIE_SECURE = SHOULD_BE_SECURE
198+
194199
SOCIAL_AUTH_PEBBLE_REQUIRED = 'PEBBLE_AUTH_REQUIRED' in _environ
195200

196201
ROOT_URLCONF = 'cloudpebble.urls'
@@ -255,7 +260,15 @@
255260
}
256261
}
257262

258-
BROKER_URL = _environ.get('CLOUDAMQP_URL', 'amqp://guest:guest@localhost:5672/')
263+
REDIS_URL = _environ.get('REDIS_URL', None) or _environ.get('REDISCLOUD_URL', 'redis://redis:6379')
264+
265+
BROKER_URL = REDIS_URL + '/1'
266+
CELERY_RESULT_BACKEND = BROKER_URL
267+
CELERY_ACCEPT_CONTENT = ['pickle']
268+
CELERY_TASK_SERIALIZER = 'pickle'
269+
270+
CELERYD_TASK_TIME_LIMIT = int(_environ.get('CELERYD_TASK_TIME_LIMIT', 620))
271+
CELERYD_TASK_SOFT_TIME_LIMIT = int(_environ.get('CELERYD_TASK_SOFT_TIME_LIMIT', 600))
259272

260273
BROKER_POOL_LIMIT = int(_environ.get('BROKER_POOL_LIMIT', 10))
261274

@@ -278,10 +291,10 @@
278291

279292
GITHUB_HOOK_TEMPLATE = _environ.get('GITHUB_HOOK', 'http://example.com/ide/project/%(project)d/github/push_hook?key=%(key)s')
280293

281-
SDK2_PEBBLE_TOOL = _environ.get('SDK2_PEBBLE_TOOL', '/home/vagrant/sdk2/bin/pebble')
282-
SDK3_PEBBLE_TOOL = _environ.get('SDK3_PEBBLE_TOOL', '/home/vagrant/sdk3/bin/pebble')
294+
SDK2_PEBBLE_WAF = _environ.get('SDK2_PEBBLE_WAF', '/sdk2/pebble/waf')
295+
SDK3_PEBBLE_WAF = _environ.get('SDK3_PEBBLE_WAF', '/sdk3/pebble/waf')
283296

284-
ARM_CS_TOOLS = _environ.get('ARM_CS_TOOLS', '/home/vagrant/arm-cs-tools/bin/')
297+
ARM_CS_TOOLS = _environ.get('ARM_CS_TOOLS', '/arm-cs-tools/bin/')
285298

286299
KEEN_PROJECT_ID = _environ.get('KEEN_PROJECT_ID', None)
287300
KEEN_WRITE_KEY = _environ.get('KEEN_WRITE_KEY', None)
@@ -294,20 +307,19 @@
294307
AWS_ACCESS_KEY_ID = _environ.get('AWS_ACCESS_KEY_ID', None)
295308
AWS_SECRET_ACCESS_KEY = _environ.get('AWS_SECRET_ACCESS_KEY', None)
296309

297-
AWS_S3_SOURCE_BUCKET = _environ.get('AWS_S3_SOURCE_BUCKET', None)
298-
AWS_S3_BUILDS_BUCKET = _environ.get('AWS_S3_BUILDS_BUCKET', None)
299-
AWS_S3_EXPORT_BUCKET = _environ.get('AWS_S3_EXPORT_BUCKET', None)
310+
AWS_S3_SOURCE_BUCKET = _environ.get('AWS_S3_SOURCE_BUCKET', 'source.cloudpebble.net')
311+
AWS_S3_BUILDS_BUCKET = _environ.get('AWS_S3_BUILDS_BUCKET', 'builds.cloudpebble.net')
312+
AWS_S3_EXPORT_BUCKET = _environ.get('AWS_S3_EXPORT_BUCKET', 'exports.cloudpebble.net')
313+
AWS_S3_FAKE_S3 = _environ.get('AWS_S3_FAKE_S3', None)
300314

301315
TYPOGRAPHY_CSS = _environ.get('TYPOGRAPHY_CSS', None)
302316

303-
REDIS_URL = _environ.get('REDIS_URL', None) or _environ.get('REDISCLOUD_URL', 'redis://localhost:6379/')
304-
305317
LIBPEBBLE_PROXY = _environ.get('LIBPEBBLE_PROXY', None)
306318

307319
YCM_URLS = _environ.get('YCM_URLS', 'http://localhost:8002/').split(',')
308320
COMPLETION_CERTS = _environ.get('COMPLETION_CERTS', os.getcwd() + '/completion-certs.crt')
309321

310-
QEMU_URLS = _environ.get('QEMU_URLS', 'http://192.168.42.42:8003/').split(',')
322+
QEMU_URLS = _environ.get('QEMU_URLS', 'http://qemu/').split(',')
311323
QEMU_LAUNCH_AUTH_HEADER = _environ.get('QEMU_LAUNCH_AUTH_HEADER', 'secret')
312324
QEMU_LAUNCH_TIMEOUT = int(_environ.get('QEMU_LAUNCH_TIMEOUT', 15))
313325

@@ -323,10 +335,12 @@
323335
print "No local settings overrides."
324336
pass
325337

338+
socket.setdefaulttimeout(int(_environ.get("DEFAULT_SOCKET_TIMEOUT", 10)))
339+
326340
# Don't keep these hanging around in the environment.
327341
if not DEBUG:
328342
for key in _environ.keys():
329343
# We need these ones to run.
330-
if key in {'PATH', 'TZ', 'RUN_MAIN', 'CELERY_LOADER', 'DJANGO_SETTINGS_MODULE', 'DEBUG'}:
344+
if key in {'PATH', 'TZ', 'RUN_MAIN', 'CELERY_LOADER', 'DJANGO_SETTINGS_MODULE', 'DEBUG', 'C_FORCE_ROOT'}:
331345
continue
332346
del _environ[key]

docker_start.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
sleep 1
3+
if [ ! -z "$RUN_WEB" ]; then
4+
# Make sure the database is up to date.
5+
echo "Performing database migration."
6+
python manage.py syncdb --noinput
7+
python manage.py migrate
8+
9+
python manage.py runserver 0.0.0.0:$PORT
10+
elif [ ! -z "$RUN_CELERY" ]; then
11+
sleep 2
12+
C_FORCE_ROOT=true python manage.py celery worker --autoreload --loglevel=info
13+
else
14+
echo "Doing nothing!"
15+
exit 1
16+
fi

fabfile.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def restart_qemu_service():
6060
@parallel
6161
def update_ycmd_sdk(sdk_version):
6262
with cd("/home/ycm"), settings(sudo_user="ycm", shell="/bin/bash -c"):
63-
sudo("wget -nv -O sdk.tar.gz https://sdk.getpebble.com/download/%s?source=cloudpebble" % sdk_version)
63+
sudo("wget -nv -O sdk.tar.gz https://s3.amazonaws.com/assets.getpebble.com/sdk3/release/sdk-core-%s.tar.bz2" % sdk_version)
6464
sudo("tar -xf sdk.tar.gz")
6565
sudo("rm -rf sdk3")
66-
sudo("mv PebbleSDK-%s sdk3" % sdk_version)
66+
sudo("mv sdk-core sdk3")
6767

6868

6969
@task
@@ -123,6 +123,7 @@ def update_qemu_images(sdk_version):
123123
with lcd("~/projects/tintin"):
124124
local("git checkout v%s" % sdk_version)
125125

126+
build_qemu_image("bb2", "aplite")
126127
build_qemu_image("snowy_bb", "basalt")
127128
build_qemu_image("spalding_bb2", "chalk")
128129

@@ -134,7 +135,7 @@ def update_qemu_images(sdk_version):
134135
@task
135136
@runs_once
136137
def update_cloudpebble_sdk(sdk_version):
137-
local("sed -i.bak 's/download\/3.[a-z0-9-]*/download\/%s/' bin/post_compile bootstrap.sh" % sdk_version)
138+
local("sed -i.bak 's/sdk-core-3.[a-z0-9-]*\.tar\.bz2/sdk-core-%s.tar.bz2/' bin/post_compile bootstrap.sh" % sdk_version)
138139
local("git add bin/post_compile bootstrap.sh")
139140
local("git commit -m 'Update to v%s'" % sdk_version)
140141
local("git push")

ide/api/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def project_info(request, project_id):
5151
'file_name': x.file_name,
5252
'kind': x.kind,
5353
'identifiers': [y.resource_id for y in x.identifiers.all()],
54-
'extra': {y.resource_id: {'regex': y.character_regex, 'tracking': y.tracking, 'compatibility': y.compatibility} for y in x.identifiers.all()},
54+
'extra': {y.resource_id: y.get_options_dict(with_id=False) for y in x.identifiers.all()},
5555
'variants': [y.get_tags() for y in x.variants.all()],
5656
} for x in resources],
5757
'github': {

ide/api/qemu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def launch_emulator(request):
2424
oauth = request.POST['token']
2525
tz_offset = request.POST['tz_offset']
2626
versions = {
27-
'aplite': '2.9',
27+
'aplite': '3.0',
2828
'basalt': '3.0',
2929
'chalk': '3.0',
3030
}

0 commit comments

Comments
 (0)