feat: upgrade to nutmeg
This commit is contained in:
parent
dff318bd2e
commit
ea3fbafcaf
@ -2,7 +2,7 @@ variables:
|
||||
TUTOR_PLUGIN: xqueue
|
||||
TUTOR_IMAGES: xqueue
|
||||
TUTOR_PYPI_PACKAGE: tutor-xqueue
|
||||
OPENEDX_RELEASE: maple
|
||||
OPENEDX_RELEASE: nutmeg
|
||||
GITHUB_REPO: overhangio/tutor-xqueue
|
||||
|
||||
include:
|
||||
|
||||
8
setup.py
8
setup.py
@ -31,17 +31,15 @@ setup(
|
||||
long_description_content_type="text/x-rst",
|
||||
packages=find_packages(exclude=["tests*"]),
|
||||
include_package_data=True,
|
||||
python_requires=">=3.5",
|
||||
install_requires=["tutor>=13.0.0,<14.0.0", "requests"],
|
||||
entry_points={"tutor.plugin.v0": ["xqueue = tutorxqueue.plugin"]},
|
||||
python_requires=">=3.7",
|
||||
install_requires=["tutor>=14.0.0,<15.0.0", "requests"],
|
||||
entry_points={"tutor.plugin.v1": ["xqueue = tutorxqueue.plugin"]},
|
||||
classifiers=[
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: GNU Affero General Public License v3",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
|
||||
@ -1 +1 @@
|
||||
__version__ = "13.0.0"
|
||||
__version__ = "14.0.0"
|
||||
|
||||
@ -7,13 +7,14 @@ import pkg_resources
|
||||
import requests
|
||||
|
||||
from tutor import config as tutor_config
|
||||
from tutor import hooks as tutor_hooks
|
||||
from tutor.exceptions import TutorError
|
||||
|
||||
from .__about__ import __version__
|
||||
|
||||
|
||||
config = {
|
||||
"add": {
|
||||
"unique": {
|
||||
"AUTH_PASSWORD": "{{ 8|random_string }}",
|
||||
"MYSQL_PASSWORD": "{{ 8|random_string }}",
|
||||
"SECRET_KEY": "{{ 24|random_string }}",
|
||||
@ -28,25 +29,33 @@ config = {
|
||||
},
|
||||
}
|
||||
|
||||
templates = pkg_resources.resource_filename("tutorxqueue", "templates")
|
||||
hooks = {
|
||||
"init": ["mysql", "xqueue"],
|
||||
"build-image": {"xqueue": "{{ XQUEUE_DOCKER_IMAGE }}"},
|
||||
"remote-image": {"xqueue": "{{ XQUEUE_DOCKER_IMAGE }}"},
|
||||
}
|
||||
# Inizialization hooks
|
||||
tutor_hooks.Filters.COMMANDS_INIT.add_item((
|
||||
"mysql",
|
||||
("xqueue", "tasks", "mysql", "init"),
|
||||
))
|
||||
|
||||
tutor_hooks.Filters.COMMANDS_INIT.add_item((
|
||||
"xqueue",
|
||||
("xqueue", "tasks", "xqueue", "init"),
|
||||
))
|
||||
|
||||
def patches():
|
||||
all_patches = {}
|
||||
for path in glob(
|
||||
os.path.join(pkg_resources.resource_filename("tutorxqueue", "patches"), "*")
|
||||
):
|
||||
with open(path) as patch_file:
|
||||
name = os.path.basename(path)
|
||||
content = patch_file.read()
|
||||
all_patches[name] = content
|
||||
return all_patches
|
||||
# Image managment
|
||||
tutor_hooks.Filters.IMAGES_BUILD.add_item((
|
||||
"xqueue",
|
||||
("plugins", "xqueue", "build", "xqueue"),
|
||||
"{{ XQUEUE_DOCKER_IMAGE }}",
|
||||
(),
|
||||
))
|
||||
|
||||
tutor_hooks.Filters.IMAGES_PULL.add_item((
|
||||
"xqueue",
|
||||
"{{ XQUEUE_DOCKER_IMAGE }}",
|
||||
))
|
||||
tutor_hooks.Filters.IMAGES_PUSH.add_item((
|
||||
"xqueue",
|
||||
"{{ XQUEUE_DOCKER_IMAGE }}",
|
||||
))
|
||||
|
||||
@click.group(help="Interact with the Xqueue server")
|
||||
def command():
|
||||
@ -199,3 +208,39 @@ submissions.add_command(count_submissions)
|
||||
submissions.add_command(show_submission)
|
||||
submissions.add_command(grade_submission)
|
||||
command.add_command(submissions)
|
||||
|
||||
####### Boilerplate code
|
||||
# Add the "templates" folder as a template root
|
||||
tutor_hooks.Filters.ENV_TEMPLATE_ROOTS.add_item(
|
||||
pkg_resources.resource_filename("tutorxqueue", "templates")
|
||||
)
|
||||
# Render the "build" and "apps" folders
|
||||
tutor_hooks.Filters.ENV_TEMPLATE_TARGETS.add_items(
|
||||
[
|
||||
("xqueue/build", "plugins"),
|
||||
("xqueue/apps", "plugins"),
|
||||
],
|
||||
)
|
||||
# Load patches from files
|
||||
for path in glob(
|
||||
os.path.join(
|
||||
pkg_resources.resource_filename("tutorxqueue", "patches"),
|
||||
"*",
|
||||
)
|
||||
):
|
||||
with open(path, encoding="utf-8") as patch_file:
|
||||
tutor_hooks.Filters.ENV_PATCHES.add_item((os.path.basename(path), patch_file.read()))
|
||||
# Add configuration entries
|
||||
tutor_hooks.Filters.CONFIG_DEFAULTS.add_items(
|
||||
[
|
||||
(f"XQUEUE_{key}", value)
|
||||
for key, value in config.get("defaults", {}).items()
|
||||
]
|
||||
)
|
||||
tutor_hooks.Filters.CONFIG_UNIQUE.add_items(
|
||||
[
|
||||
(f"XQUEUE_{key}", value)
|
||||
for key, value in config.get("unique", {}).items()
|
||||
]
|
||||
)
|
||||
tutor_hooks.Filters.CONFIG_OVERRIDES.add_items(list(config.get("overrides", {}).items()))
|
||||
|
||||
4
tutorxqueue/templates/xqueue/tasks/mysql/init
Normal file
4
tutorxqueue/templates/xqueue/tasks/mysql/init
Normal file
@ -0,0 +1,4 @@
|
||||
mysql -u {{ MYSQL_ROOT_USERNAME }} --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e 'CREATE DATABASE IF NOT EXISTS {{ XQUEUE_MYSQL_DATABASE }};'
|
||||
mysql -u {{ MYSQL_ROOT_USERNAME }} --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e "CREATE USER IF NOT EXISTS '{{ XQUEUE_MYSQL_USERNAME }}';"
|
||||
mysql -u {{ MYSQL_ROOT_USERNAME }} --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e "ALTER USER '{{ XQUEUE_MYSQL_USERNAME }}'@'%' IDENTIFIED BY '{{ XQUEUE_MYSQL_PASSWORD }}';"
|
||||
mysql -u {{ MYSQL_ROOT_USERNAME }} --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e "GRANT ALL ON {{ XQUEUE_MYSQL_DATABASE }}.* TO '{{ XQUEUE_MYSQL_USERNAME }}'@'%';"
|
||||
2
tutorxqueue/templates/xqueue/tasks/xqueue/init
Normal file
2
tutorxqueue/templates/xqueue/tasks/xqueue/init
Normal file
@ -0,0 +1,2 @@
|
||||
./manage.py migrate
|
||||
./manage.py update_users
|
||||
Loading…
x
Reference in New Issue
Block a user