Included argparser for warp
optional options disabled by default
This commit is contained in:
parent
a0495a6f85
commit
b30fd580c2
3 changed files with 27 additions and 9 deletions
25
warp/hook.py
25
warp/hook.py
|
@ -1,5 +1,6 @@
|
|||
import sys
|
||||
import io
|
||||
import argparse
|
||||
|
||||
from threading import Thread, Event
|
||||
from multiprocessing import Queue
|
||||
|
@ -32,11 +33,16 @@ class QueuedOut(io.StringIO):
|
|||
|
||||
|
||||
class FlaskThread(Thread):
|
||||
def __init__(self, port, host):
|
||||
super().__init__()
|
||||
self.port = port
|
||||
self.host = host
|
||||
|
||||
def run(self):
|
||||
views.app.run(threaded=True)
|
||||
views.app.run(port=self.port, threaded=True, host=self.host)
|
||||
|
||||
|
||||
def start_module(name):
|
||||
def start_module(name, is_module):
|
||||
views.app.restart.clear()
|
||||
views.app.name = ""
|
||||
views.app.desc = ""
|
||||
|
@ -55,7 +61,8 @@ def start_module(name):
|
|||
name,
|
||||
ioout,
|
||||
ioerr,
|
||||
overwritten_modules={'argparse': argparser}
|
||||
overwritten_modules={'argparse': argparser},
|
||||
is_module = is_module
|
||||
)
|
||||
views.app.module_process.start()
|
||||
views.app.module_process.join()
|
||||
|
@ -65,12 +72,20 @@ def start_module(name):
|
|||
|
||||
|
||||
def main():
|
||||
flask_thread = FlaskThread()
|
||||
|
||||
parser = argparse.ArgumentParser(description="a Webbased frontend for ARgparse in Python")
|
||||
parser.add_argument('--port', '-p', default=5000, help="The port to listen on (default 5000)")
|
||||
parser.add_argument('--host', default="0.0.0.0", help="The host to bind to (default 0.0.0.0)")
|
||||
parser.add_argument('--module', '-m', action="store_true", help="If set, loads a module instead of a file")
|
||||
parser.add_argument('file', help="File to run")
|
||||
args = parser.parse_args()
|
||||
|
||||
flask_thread = FlaskThread(args.port, args.host)
|
||||
flask_thread.start()
|
||||
|
||||
views.app.restart = Event()
|
||||
while True:
|
||||
start_module(sys.argv[1])
|
||||
start_module(args.file, args.module)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -131,9 +131,9 @@ function createAction(action) {
|
|||
var inputdiv = $("<div/>").addClass("columns small-5").appendTo(row)
|
||||
var deldiv = $("<div/>").addClass("columns small-2").appendTo(row);
|
||||
if(action['is_const']) {
|
||||
createCheckboxAction(action).addClass("float-right").appendTo(inputdiv);
|
||||
var input = createCheckboxAction(action).addClass("float-right").appendTo(inputdiv);
|
||||
} else {
|
||||
createInputAction(action).addClass("float-right").appendTo(inputdiv);
|
||||
var input = createInputAction(action).addClass("float-right").appendTo(inputdiv);
|
||||
}
|
||||
if(action.desc !== null) {
|
||||
var help = $("<button/>", {"type": "button", "data-open": 'modal_' + action['uuid']})
|
||||
|
@ -146,6 +146,11 @@ function createAction(action) {
|
|||
var help = $("<button/>").attr("type", "button").addClass("button disabled secondary").text("?").appendTo(helpdiv);
|
||||
}
|
||||
if(action.optional === true) {
|
||||
li.prop('disabled', true);
|
||||
input.prop('disabled', true).addClass('disabled');
|
||||
input.find('input').prop('disabled', true).addClass('disabled');
|
||||
input.find('.addbutton').prop('disabled', true).addClass('disabled');
|
||||
input.find('.rembutton').prop('disabled', true).addClass('disabled');
|
||||
var del = $("<button/>").attr("type", "button").addClass("button delbutton alert").html("×").appendTo(deldiv);
|
||||
del.click(function() {
|
||||
thisli = $('#action-' + action['uuid']);
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
<script src="{{ url_for('static', filename='js/vendor/jquery.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/vendor/foundation.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/vendor/foundation.sticky.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/vendor/socket.io.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/oboe-browser.min.js') }}"></script>
|
||||
|
||||
</head>
|
||||
|
|
Loading…
Add table
Reference in a new issue