Skip to content

Commit

Permalink
Merge pull request #36 from GuillaumeDerval/backend_v4
Browse files Browse the repository at this point in the history
Let me introduce you the new backend.
  • Loading branch information
GuillaumeDerval committed Jun 28, 2015
2 parents e8e6e82 + ad6b8c5 commit b031751
Show file tree
Hide file tree
Showing 489 changed files with 4,777 additions and 3,716 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dump
doc/_*
tasks
!tests/tasks
!*/tests/tasks
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ load-plugins=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=R0201,R0903,R0911,R0913,R0922
disable=R0201,R0903,R0911,R0913,R0922,W0704,W0703,W0702


[REPORTS]
Expand Down Expand Up @@ -228,7 +228,7 @@ ignored-modules=

# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set).
ignored-classes=SQLObject
ignored-classes=SQLObject,_socketobject

# When zope mode is activated, add a predefined set of Zope acquired attributes
# to generated-members.
Expand Down
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# the code for this .Travis.yml has been mostly taken from https://github.com/haiwen/seafile-docker/blob/master/.travis.yml
language: python
python:
- "2.7"
env:
global:
- "HOST_IP=$(/sbin/ifconfig venet0:0 | grep 'inet addr' | awk -F: '{print $2}' | awk '{print $1}')"
- DOCKER_HOST=tcp://$HOST_IP:2375
- SLIRP_PORTS=$(seq 2375 2500)
- TEST_DOCKER_JOB_MANAGER=travis
before_install:
- echo exit 101 | sudo tee /usr/sbin/policy-rc.d
- sudo chmod +x /usr/sbin/policy-rc.d
install:
- curl -sSL https://get.docker.com/ | sh
- sudo apt-get install slirp
- sudo usermod -aG docker "$USER"
- git clone git://github.com/cptactionhank/sekexe
- "pip install pymongo pytidylib docker-py sh web.py docutils simpleldap pyyaml rpyc cgroup-utils"
before_script:
- "sekexe/run 'mount -t tmpfs -o size=8g tmpfs /var/lib/docker && docker -d -H tcp://0.0.0.0:2375' &"
- "while ! docker info &> /dev/null ; do echo 'retrying to connect to docker...'; sleep 1; done"
script: nosetests .
62 changes: 62 additions & 0 deletions app_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014-2015 Université Catholique de Louvain.
#
# This file is part of INGInious.
#
# INGInious is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# INGInious is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with INGInious. If not, see <http://www.gnu.org/licenses/>.
""" Starts an agent """

import logging
import os
from backend_agent.agent import RemoteAgent
import common.base
import argparse

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("port", help="Port to listen to", type=int)
parser.add_argument("--dir", help="Path to a directory where the agent can store information, such as caches. Defaults to ./agent_data",
default="./agent_data")
parser.add_argument("--tasks", help="Path to the task directory. By default, it is hidden by the agent and automatically synchronized with the "
"backend; if you define this argument, automatic sync will be disabled.")
args = parser.parse_args()

if not os.path.exists(args.dir):
os.makedirs(args.dir)
if not os.path.exists(os.path.join(args.dir, 'tmp')):
os.makedirs(os.path.join(args.dir, 'tmp'))
if args.tasks is None:
taskdir = os.path.join(args.dir, 'tasks')
sync_enabled = True
else:
taskdir = args.tasks
sync_enabled = False

if not os.path.exists(taskdir):
os.makedirs(taskdir)

common.base.init_common_lib(taskdir, [], 1) # we do not need to upload file, so not needed here

# create logger
logger = logging.getLogger("agent")
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
ch.setFormatter(formatter)
logger.addHandler(ch)

RemoteAgent(args.port, os.path.join(args.dir, 'tmp'), sync_enabled)
66 changes: 5 additions & 61 deletions app_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,69 +19,13 @@
# License along with INGInious. If not, see <http://www.gnu.org/licenses/>.
""" Starts the frontend """

import os.path

import web

import common.base
from frontend import submission_manager
import frontend.base
from frontend.database_updater import update_database
from frontend.plugins.plugin_manager import PluginManager
import frontend.session
from frontend.template_helper import TemplateHelper
urls = (
'/', 'frontend.pages.index.IndexPage',
'/index', 'frontend.pages.index.IndexPage',
'/course/([^/]+)', 'frontend.pages.course.CoursePage',
'/course/([^/]+)/([^/]+)', 'frontend.pages.tasks.TaskPage',
'/course/([^/]+)/([^/]+)/(.*)', 'frontend.pages.tasks.TaskPageStaticDownload',
'/admin/([^/]+)', 'frontend.pages.course_admin.settings.CourseSettings',
'/admin/([^/]+)/settings', 'frontend.pages.course_admin.settings.CourseSettings',
'/admin/([^/]+)/students', 'frontend.pages.course_admin.student_list.CourseStudentListPage',
'/admin/([^/]+)/student/([^/]+)', 'frontend.pages.course_admin.student_info.CourseStudentInfoPage',
'/admin/([^/]+)/student/([^/]+)/([^/]+)', 'frontend.pages.course_admin.student_task.CourseStudentTaskPage',
'/admin/([^/]+)/student/([^/]+)/([^/]+)/([^/]+)', 'frontend.pages.course_admin.student_task.SubmissionDownloadFeedback',
'/admin/([^/]+)/tasks', 'frontend.pages.course_admin.task_list.CourseTaskListPage',
'/admin/([^/]+)/task/([^/]+)', 'frontend.pages.course_admin.task_info.CourseTaskInfoPage',
'/admin/([^/]+)/edit/([^/]+)', 'frontend.pages.course_admin.task_edit.CourseEditTask',
'/admin/([^/]+)/edit/([^/]+)/files', 'frontend.pages.course_admin.task_edit_file.CourseTaskFiles',
'/admin/([^/]+)/submissions', 'frontend.pages.course_admin.submission_files.DownloadSubmissionFiles'
)


def get_app(config_file):
""" Get the application. config_file is the path to the JSON configuration file """
appli = web.application(urls, globals(), autoreload=False)
common.base.INGIniousConfiguration.load(config_file)

frontend.base.init_database()
update_database()
frontend.session.init(appli)

def not_found():
""" Display the error 404 page """
return web.notfound(frontend.base.renderer.notfound('Page not found'))
appli.notfound = not_found

plugin_manager = PluginManager(appli, common.base.INGIniousConfiguration.get("plugins", []))

# Plugin Manager is also a Hook Manager
submission_manager.init_backend_interface(plugin_manager)

# Loads template_helper
TemplateHelper()

# Loads plugins
plugin_manager.load()

return appli
import frontend.app
import os

if __name__ == "__main__":
if os.path.isfile("./configuration.yaml"):
app = get_app("./configuration.yaml")
frontend.app.start_app("./configuration.yaml")
elif os.path.isfile("./configuration.json"):
app = get_app("./configuration.json")
frontend.app.start_app("./configuration.json")
else:
raise Exception("No configuration file found")
app.run()
raise Exception("No configuration file found")
12 changes: 6 additions & 6 deletions backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014-2015 Université Catholique de Louvain.
#
#
# Copyright (c) 2014 Université Catholique de Louvain.
#
# This file is part of INGInious.
#
#
# INGInious is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# INGInious is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
#
# You should have received a copy of the GNU Affero General Public
# License along with INGInious. If not, see <http://www.gnu.org/licenses/>.

Expand Down
139 changes: 0 additions & 139 deletions backend/_callback_manager.py

This file was deleted.

37 changes: 0 additions & 37 deletions backend/_event_reader.py

This file was deleted.

0 comments on commit b031751

Please sign in to comment.