diff options
Diffstat (limited to 'python/tasks.py')
| -rw-r--r-- | python/tasks.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/python/tasks.py b/python/tasks.py index 8f646fdb..f50d8e13 100644 --- a/python/tasks.py +++ b/python/tasks.py @@ -19,3 +19,20 @@ def build_scenarios(workdate, dealname, reinvflag): with open(os.path.join(logpath, "build_scenarios.Rout"), "w") as fh: subprocess.call(args, stderr=subprocess.STDOUT, stdout=fh, env=os.environ, cwd=rpath) + +class Rpc(object): + def __init__(self, fun, args): + self.fun = fun + self.args = args + + def __str__(self): + return dumps({'fun': self.fun, + 'args': self.args}) + def __call__(self): + globals()[self.fun](*self.args) + + @classmethod + def from_json(cls, s): + rpc = loads(s) + instance = cls(rpc['fun'], rpc['args']) + return instance |
