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

Add some useability code #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions Scripting-Tool/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: bioschemasmarkupgenerator
channels:
- conda-forge
- defaults
dependencies:
- python
- pyyaml
- requests
4 changes: 2 additions & 2 deletions Web-Application/libs/bioschemas/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//GLOBAL VARIABLES
var editor;
var dropdownArray = new Array();
var websiteURL = "https://www.macs.hw.ac.uk/SWeL/BioschemasGenerator"
var websiteURL = "http://localhost:8080/"
//JSON Editor Settings
JSONEditor.defaults.theme = 'bootstrap4';
JSONEditor.defaults.options["display_required_only"] = true;
Expand Down Expand Up @@ -86,7 +86,7 @@ function listOfFiles(websiteURL) {
$.ajax({
url: websiteURL,
success: function (data) {
$(data).find("td > a").each(function () {
$(data).find("li > a").each(function () {
//If file is a JSON Schema file add to list
if ((/\.(json)$/i).test($(this).attr("href"))) {
fileNames.push($(this).attr("href"));
Expand Down
44 changes: 44 additions & 0 deletions run_web_application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3

# run the web application using Docker

import argparse
import os
import shutil
import sys
from shlex import split
from subprocess import run

def run_scripting_tool():
# run the scripting tool to generate the profiles
# this requires python3, pyyaml and requests
# TODO: write this function
pass

def update_profiles():
# update the profiles in the Web-Application directory
for dir in ['profiles', 'tables', 'draft-profiles', 'draft-tables']:
shutil.rmtree(f'Web-Application/{dir}', ignore_errors=True)
shutil.copytree(f'Scription-Tool/{dir}', f'Web-Application/{dir}')


def run_web_application():
# run the web application using Docker
cmd_str = f'docker run --rm --name BioschemasMarkupGenerator -p 8080:80 -v {os.getcwd()}/Web-Application:/usr/local/apache2/htdocs httpd'
cmd = split(cmd_str)
run(cmd)


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run the web application using Docker')
parser.add_argument('--update_profiles', action='store_true', help='Update the profiles in the Web-Application directory')
parser.add_argument('--regenerate_profiles', action='store_true', help='Regenerate the profiles in the Scription-Tool directory')
args = parser.parse_args()

if args.regenerate_profiles:
run_scripting_tool()
sys.exit(0)

if args.update_profiles:
update_profiles()
run_web_application()