Compare commits

..

No commits in common. "master" and "0.1.1" have entirely different histories.

9 changed files with 21 additions and 57 deletions

View file

@ -1,6 +1,6 @@
from setuptools import setup, find_packages
version = "0.1.2"
version = "0.1.1"
setup(
name='warped',

View file

@ -90,7 +90,7 @@ class ActionContainer():
internal_dict = {}
internal_dict['uuid'] = str(self.uuid)
internal_dict['actions'] = [action.as_dict() for action in self.actions]
internal_dict['groups'] = [group.as_dict() for group in self.groups]
internal_dict['groups'] = [[action.as_dict() for action in group] for group in self.groups]
return internal_dict
class StoreAction(Action):
@ -98,8 +98,6 @@ class StoreAction(Action):
class StoreConstAction(Action):
def store_type_function(self, x):
if x == 'false':
x = None
return self.const if x is not None else self.on_none
def __init__(self, action, **kwargs):
@ -112,4 +110,4 @@ class MutuallyExclusiveGroup(ActionContainer):
super().__init__()
def __repr__(self):
return "Group Object: ( Actions: {}, Groups: {} )".format(self.actions, self.groups)
return "Group Object: ( Actions: {}, Groups: {} )".format(self.actions, self.mutex_groups)

View file

@ -1,5 +1,6 @@
import argparse
import sys
import io
import runpy
from traceback import print_exc
from contextlib import redirect_stdout, redirect_stderr
@ -23,10 +24,9 @@ class Context(Process):
sys.argv = [''] + self.arguments
else:
sys.argv = ['']
# if not self.original_modules is None:
# sys.modules.clear()
# sys.modules.update(self.original_modules)
#if not self.original_modules is None:
# sys.modules = self.original_modules
# print(sys.modules)
sys.modules.update(self.overwritten_modules)
with redirect_stdout(self.stdout):
with redirect_stderr(self.stderr):

View file

@ -1,4 +1,3 @@
from . import savemodules
import sys
import io
@ -25,15 +24,9 @@ class QueuedOut(io.StringIO):
lines = b.split('\n')
for line in lines[:-1]:
super().write(line)
self.explflush()
self.flush()
super().write(lines[-1])
def explflush(self):
value = self.getvalue()
self.queue.put((self.name, value))
self.seek(0)
self.truncate(0)
def flush(self):
value = self.getvalue()
if len(value) > 1:
@ -107,7 +100,7 @@ def start_module(name, is_module):
ioerr,
overwritten_modules={'argparse': argparser},
is_module = is_module,
original_modules = savemodules.savedmodules
#original_modules = emptymodules
)
views.app.module_process.start()
views.app.output.start()
@ -119,7 +112,6 @@ def start_module(name, is_module):
views.app.output.stop()
ioerr.write("Process stopped ({})\n".format(views.app.module_process.exitcode))
views.app.output.queue.put(("sig", "stop"))
views.app.restart.wait()

View file

@ -11,4 +11,3 @@ if __name__ == "__main__":
args = parser.parse_args()
print("Subparser %s was selected" % args.command)
print(args)

View file

@ -1,2 +0,0 @@
import sys
savedmodules = dict(sys.modules)

View file

@ -7,15 +7,6 @@
display: block;
}
.checkbox {
height:100%;
}
input[type=checkbox] {
width: 2em;
height: 2em;
-moz-appearance: none;
}
#output {
flex:1;

View file

@ -21,9 +21,6 @@ function createSubparserAction(action) {
var content_div = $("<div/>", { id: choice['uuid'] })
.addClass("tabs-panel").appendTo(tab_content);
choice['groups'].forEach(function(group) {
content_div.append(createGroup(group));
});
choice['actions'].forEach(function(action) {
content_div.append(createAction(action));
});
@ -34,14 +31,13 @@ function createSubparserAction(action) {
}
function createCheckboxAction(action) {
//var switch_div = $("<div/>").addClass("switch");
var switch_div = $("<div/>").addClass("checkbox");
var switch_div = $("<div/>").addClass("switch");
var input = $("<input/>", {
id: action["uuid"],
type: 'checkbox',
name: action['uuid']
}).data("name", action['dest']).appendTo(switch_div);
var paddle = $("<label/>", {for: action["uuid"]}).addClass("css-label")
}).addClass('switch-input').data("name", action['dest']).appendTo(switch_div);
var paddle = $("<label/>", {for: action["uuid"]}).addClass("switch-paddle")
.appendTo(switch_div);
if(action['checked'] === true) {
input.attr('checked', true);

View file

@ -12,33 +12,21 @@ from flask import Flask, render_template, request, Response, \
app = Flask(__name__)
app.mutex_groups=[]
def parse_argument(name, json, action, namespace):
def parse_argument(name, json, action):
try:
argument = json[name]
if type(argument) == list:
if len(argument) == 1:
setattr(namespace, action.name, action.type_function(argument[0]))
return action.type_function(argument[0])
else:
setattr(namespace, action.name, [action.type_function(elem) for elem in argument])
return [action.type_function(elem) for elem in argument]
else:
setattr(namespace, action.name, action.type_function(argument))
return action.type_function(argument)
except (KeyError, ValueError):
if name.endswith("[]"):
setattr(namespace, action.name, action.on_none)
return action.on_none
else:
parse_argument(name + "[]", json, action, namespace)
try:
for name, choice in action.choices.items():
actions = choice.actions
for group in choice.groups:
actions.extend(group.actions)
for act in actions:
parse_argument(act.name, json, act, namespace)
except AttributeError:
pass
return parse_argument(name + "[]", json, action)
@app.route("/arguments", methods=['POST'])
@ -51,7 +39,8 @@ def fill_namespace():
all_actions.extend(group.actions)
for action in all_actions:
parse_argument(action.name, json, action, namespace)
value = parse_argument(action.name, json, action)
setattr(namespace, action.name, value)
app.namespaceQueue.put(namespace)
app.output.queue.put(("sig", "start"))
@ -68,6 +57,7 @@ def get_arguments():
def stop():
os.kill(app.module_process.pid, signal.SIGCONT)
app.module_process.terminate()
app.output.queue.put(("sig", "stop"))
return "OK"
@app.route("/resume")