Skip to content

Commit

Permalink
Add options for starting html server and meteor
Browse files Browse the repository at this point in the history
  • Loading branch information
Shotgunosine committed Feb 15, 2018
1 parent 3f7bbc9 commit 932056a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions auto_mindcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
from pathlib import Path
import json
from bids.grabbids import BIDSLayout
import subprocess
import os
import shutil

parser = argparse.ArgumentParser(description='Autogenerate mindcontrol settings from a BIDS directory')
parser.add_argument('--server', action = 'store_true',
help='Start a simple file server in the bids directory.')
parser.add_argument('--meteor', action = 'store_true',
help='Start the meteor server that will serve mindcontrol.')
parser.add_argument('bids_dir', help='The directory with the input dataset '
'formatted according to the BIDS standard.')

Expand Down Expand Up @@ -85,3 +92,10 @@
# Write out the settings file to the mindcontrol directory
with open("settings.auto.json", "w") as h:
json.dump(settings,h)

if args.server:
shutil.copy2("start_static_server.py",bids_dir)
subprocess.Popen("python start_static_server.py", cwd = bids_dir, shell = True)
if args.meteor:
meteor = subprocess.Popen("meteor --settings settings.auto.json".split(' '))
meteor.wait()
11 changes: 11 additions & 0 deletions start_static_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python
import http.server
import os

class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header("Access-Control-Allow-Origin", "*")
http.server.SimpleHTTPRequestHandler.end_headers(self)

if __name__ == '__main__':
http.server.test(HandlerClass=MyHTTPRequestHandler, port=3002)

0 comments on commit 932056a

Please sign in to comment.