Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

just some random PR for test #1

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
9aa4250
Refactor app
Jun 22, 2017
04bdd60
Merge pull request #4 from scanterog/refactor
jatindhankhar Jun 23, 2017
7de559a
Refactor code from devel branch
jatindhankhar Jun 24, 2017
5862a68
Add partial models. Added Multi Asset Pipiline and Updated requirements
jatindhankhar Jun 25, 2017
b041a51
Fix activity parsing issues
jatindhankhar Jun 27, 2017
7f95ac3
Modify Schema. Algin Build Process
jatindhankhar Jun 27, 2017
8c5f485
Complete first draft of schema. Added a method to add releases
jatindhankhar Jun 27, 2017
6db348a
Finish Schema design for Aslo. Focus on i18n and pofiles
jatindhankhar Jun 27, 2017
f281837
Add po crawler to get translation
jatindhankhar Jun 28, 2017
bce70ff
Call translation code in build pipeline
jatindhankhar Jun 28, 2017
62a45f6
Add code to extract translations
jatindhankhar Jun 29, 2017
f98dc34
Add part of the db interaction layer
jatindhankhar Jun 29, 2017
5c1c677
Re-format as per pep8. Standars. Use FloatFields for storing versions…
jatindhankhar Jun 30, 2017
53153bb
Add and initialze Imgur Client
jatindhankhar Jul 1, 2017
c940f66
Add simple docs
jatindhankhar Jul 1, 2017
09473c6
Add mock functions to upload images
jatindhankhar Jul 2, 2017
782e8db
Add Build Status to README. Add travis.yml for proper building
jatindhankhar Jul 2, 2017
0a33997
Add encrypted environment variables to avoid failed build due to abse…
jatindhankhar Jul 3, 2017
633278f
Add encrypted env file for Travis. Update instructions
jatindhankhar Jul 4, 2017
0b254bf
Fix inherting issues by placing Imgur in the root init files and remo…
jatindhankhar Jul 4, 2017
8664885
Add timeout constraint for runnable server
jatindhankhar Jul 4, 2017
ebe5c05
Using exit 0 trick to yield successful builds
jatindhankhar Jul 4, 2017
e55c513
Add conditional check for successful builds
jatindhankhar Jul 4, 2017
80dd31e
Remove Python 3.2 from build matrix
jatindhankhar Jul 4, 2017
b7fb7c5
Refactor in Progress: Streamline Asset Image Uploads
jatindhankhar Jul 4, 2017
d9e6f7b
Refactor asset processing code. Imgur doesn't allow svg uploads :sad:…
jatindhankhar Jul 4, 2017
951fa21
Complete Database integration.
jatindhankhar Jul 5, 2017
965128d
Fix DB insertion error by incoporating @scanterog's version of add re…
jatindhankhar Jul 5, 2017
77bd6ec
Simplify code for managing bundle and source code releases
scanterog Jul 7, 2017
a429253
Add service layer and image management
scanterog Jul 17, 2017
d745799
Encrypt and add Github token
jatindhankhar Jul 12, 2017
7a0f496
Add the Bot communication. Bot will post and pre build with the build…
jatindhankhar Jul 13, 2017
f118e30
pep8 fixes
scanterog Jul 17, 2017
50face4
Add starting template
jatindhankhar Jul 13, 2017
eba31c9
Add detail template. Fix image asset issue
jatindhankhar Jul 14, 2017
1c6b253
Add detail tempalte with Min Sugar version
jatindhankhar Jul 14, 2017
062d7a3
Add alternate styles for developers
jatindhankhar Jul 14, 2017
d260fe6
Add views with dynamic data
jatindhankhar Jul 14, 2017
2fb8e8e
Fix Navbar to top. Push content down. Clean the interface (remove dev…
jatindhankhar Jul 15, 2017
94b7e81
Add detail template.
jatindhankhar Jul 15, 2017
6f43510
Integrate web module with service model
scanterog Jul 17, 2017
35a7da8
Add icon rendering in pages and minor style changes
scanterog Jul 17, 2017
e9a7394
Improve performance of find tags function
jatindhankhar Jul 17, 2017
0f3b4ff
Add Github Renderer. Split Templates. Add Carousel and Sugar Image logo
jatindhankhar Jul 17, 2017
eef8cac
Move logo up in the container
jatindhankhar Jul 17, 2017
96a09b9
Add Screenshots
jatindhankhar Jul 18, 2017
9d5bc41
Add missing div inside the carousel element
jatindhankhar Jul 18, 2017
b54f3d2
Fix release body empty issue and modify the screenshot carousel
jatindhankhar Jul 19, 2017
a02ac0c
Add build support for both new and old activities by installing both …
jatindhankhar Jul 19, 2017
407ea71
Patch release to support missing po files and attributes
jatindhankhar Jul 22, 2017
ce84c0c
Add more edge case handling where po files don't have translation for…
jatindhankhar Jul 22, 2017
02a7541
Some minor fixes
scanterog Jul 24, 2017
1cda3c0
Update .travis.yml
scgnu Jul 26, 2017
0912d95
Update requirements.txt
scgnu Jul 26, 2017
59502ac
Update celery_app.py
scgnu Jul 26, 2017
693a8ef
Update README.md
scgnu Jul 26, 2017
6178a54
fix pep8
scgnu Jul 26, 2017
1d8effb
Update README.md
scgnu Feb 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .env.enc
Binary file not shown.
105 changes: 5 additions & 100 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,101 +1,6 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
*.pyc
env
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
dist
bundles
repos
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: python
python:
- '3.3'
- '3.4'
- '3.5'
- '3.6'

sudo: false
dist: trusty

install: pip install -r requirements.txt

script: cd aslo && flake8
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
site: gunicorn -c gunicorn_config.py wsgi
worker: celery -A worker worker
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
# aslo-v3
Upcoming Software center for SugarLabs (ASLO V3)
[![Build Status](https://travis-ci.org/scgnu/aslo-v3.svg?branch=master)](https://travis-ci.org/scgnu/aslo-v3)

### aslo-v3
This repo hosts the upcoming version of ASLO (Software centre) for SugarLabs.

## Setup Instructions
### Instructions

### Install virtualenv
#### Install Dependenices
**Python 3.x** supported

`pip install virtualenv`
* **Docker (System)** - For running build tasks
* **Mongo (System)** - Primary Database Engine
* **Redis (System)** - Broker for Background Tasks
* **Celery** - For running background tasks
* **Imgur** - For hosting Screenshots
* **Flower (Optional)** - Dashboard for Celery

### Create a vritualenv
`virtualenv ~/envs/flask-dev`
Install most of the app/python dependencies by running `pip install -r requirements.txt `

### Activate virtualenv
`source ~/envs/flask-dev/bin/activate`
##### How to Run

### Install Dependencies
`pip install -r requirements.txt`
`honcho` which is used in this project, looks for `.env` file, so define all the environment variables like `GITHUB_HOOK_SECRET`, `IMGUR_CLIENT_ID` , `IMGUR_CLIENT_SECRET` and others defined in the `default_settings.py`

### Install Redis
**A sample example**

``` bash
``` bash
$ cat >.env <<EOM
PORT=5000
GITHUB_HOOK_SECRET="XXXXXXXX"
IMGUR_CLIENT_ID="XXXXXXXXXXXXXXXX"
IMGUR_CLIENT_SECRET="XXXXXXXXXXXXXXX"
REDIS_URI=redis://localhost:6789/0
EOM

cd /tmp
wget http://download.redis.io/releases/redis-stable.tar.gz
tar xzf redis-stable.tar.gz
make
make test
sudo make install
```
For a more comprehensive guide follow this [Tutorial from DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04)
Run `./start.sh` to run the server

Make sure redis is running by logging in `redis-cli`

### Run the Flask Server

`python app.py` will start Flask server listening on all interfaces `0.0.0.0` and port `5000`
Run `flower -A worker --port=5555` to run the dashboard server
9 changes: 9 additions & 0 deletions activity-build-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM fedora:22

RUN dnf install -y git gettext sugar-toolkit-gtk3 sugar-toolkit

VOLUME /activity
WORKDIR /activity

CMD python /activity/setup.py dist_xo; \
chmod 777 -R /activity/
35 changes: 0 additions & 35 deletions app.py

This file was deleted.

40 changes: 40 additions & 0 deletions aslo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from flask import Flask
import logging

logger = logging.getLogger(__name__)


def init_app():
app = Flask(__name__)
app.config.from_object('aslo.settings')

# init celery
from .celery_app import init_celery
init_celery(app)

# blueprints
from .web import web
app.register_blueprint(web)

from .api import api
app.register_blueprint(api, url_prefix='/api')

# logging
logger.setLevel(logging.INFO)
fmt = logging.Formatter('[%(asctime)s] %(levelname).3s %(message)s')
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(fmt)
logger.addHandler(stream_handler)

if app.config['DEBUG']:
logger.setLevel(logging.DEBUG)

# setup db
from .service import setup_db
setup_db(app)

# custom jinja filters
from .filters import init_filters
init_filters(app)

return app
5 changes: 5 additions & 0 deletions aslo/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from flask import Blueprint

api = Blueprint('api', __name__)

from . import views, errors # noqa
12 changes: 12 additions & 0 deletions aslo/api/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import json
from flask import make_response
from . import api
from .exceptions import ApiHttpError


@api.errorhandler(ApiHttpError)
def HandleHttpApiError(e):
error_msg = json.dumps(e.to_dict())
response = make_response(error_msg, e.status_code)
response.headers['Content-Type'] = 'application/json'
return response
26 changes: 26 additions & 0 deletions aslo/api/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@


class ReleaseError(Exception):
pass


class BuildProcessError(ReleaseError):
pass


class ScreenshotDoesNotExist(ReleaseError):
pass


class ApiHttpError(Exception):

def __init__(self, message, status_code=None):
Exception.__init__(self)
self.message = message
self.status_code = status_code if status_code else 400

def to_dict(self):
return {
'message': self.message,
'status_code': self.status_code
}
51 changes: 51 additions & 0 deletions aslo/api/gh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import hmac
import hashlib
from flask import current_app as app
from urllib.parse import urlparse
from github import Github


def verify_signature(gh_signature, body, secret):
sha1 = hmac.new(secret.encode(), body, hashlib.sha1).hexdigest()
return hmac.compare_digest('sha1=' + sha1, gh_signature)


def auth():
g = Github(app.config['GITHUB_OAUTH_TOKEN'])
return g


def get_developers(repo_url):
o = urlparse(repo_url)
repo = o.path[1:].strip('.git')

g = auth()
repository = g.get_repo(repo)
contributors = repository.get_contributors()
developers = []
for c in contributors:
dev = {'email': c.email, 'page': c.html_url, 'avatar': c.avatar_url}
dev['name'] = c.name if c.name else c.login
developers.append(dev)

return developers


def find_tag_commit(repo_name, tag_name):
g = auth()
tags = g.get_repo(repo_name).get_tags()
for tag in tags:
if tag.name == tag_name:
return tag.commit

return None


def comment_on_commit(commit, message):
commit.create_comment(message)


def render_markdown(message):
# https://developer.github.com/v3/markdown/
g = auth()
return g.render_markdown(message).decode()
Loading