Commit a139915e authored by Johannes Stricker's avatar Johannes Stricker

Added --dir command line argument.

parent 9256d122
......@@ -23,6 +23,7 @@ if __name__ == "__main__":
# Parse command line arguments.
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--server', help='start a local server and add it to the host manager', default=False, action='store_true')
parser.add_argument('-d', '--dir', help='local directory to run server sessions in', type=str, default='.')
parser.add_argument('-o', '--open', help='path to a Barista project to be opened', type=str, default='')
args = parser.parse_args()
# Get caffepath out of settings.
......@@ -33,7 +34,11 @@ if __name__ == "__main__":
signal.signal(signal.SIGINT, signal.SIG_DFL)
# Start local server on 'localhost:4200' in subprocess.
if args.server:
command = './server.py --port {} --dir {}'.format(BaristaServer.DEFAULT_PORT, 'sessions')
if not os.path.exists(args.dir):
logging.error("Session folder '%s' does not exist." % (args.dir))
sys.stderr.write("Session folder '%s' does not exist." % (args.dir))
exit(2)
command = './server.py --port {} --dir {}'.format(BaristaServer.DEFAULT_PORT, args.dir)
pid = subprocess.Popen(command.split()).pid
# Stop the server when the app is about to quit.
app.aboutToQuit.connect(lambda: os.kill(pid, signal.SIGTERM))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment