diff options
author | MaZderMind <git@mazdermind.de> | 2016-08-16 13:49:50 +0200 |
---|---|---|
committer | MaZderMind <git@mazdermind.de> | 2016-08-16 13:49:50 +0200 |
commit | cb9851c0fc2d555d1630d99cc5f912ad563283d0 (patch) | |
tree | f5574f69cb2fc35eaa9c9a173b82f4aa3782c8af /voctocore | |
parent | 0d66d85cbd8d1e848b6d44a59e7babad125c5833 (diff) |
add an introspection based help-command to the control-server, fixes #59
Diffstat (limited to 'voctocore')
-rw-r--r-- | voctocore/lib/commands.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/voctocore/lib/commands.py b/voctocore/lib/commands.py index bfe3168..11cacdd 100644 --- a/voctocore/lib/commands.py +++ b/voctocore/lib/commands.py @@ -1,5 +1,6 @@ import logging import json +import inspect from lib.config import Config from lib.videomix import CompositeModes @@ -60,8 +61,54 @@ class ControlServerCommands(object): # exceptions, they will be turned into messages outside. def message(self, *args): + """sends a message through the control-server, which can be received by + user-defined scripts. does not change the state of the voctocore.""" return NotifyResponse('message', *args) + def help(self): + helplines = [] + + helplines.append("Commands:") + for name, func in ControlServerCommands.__dict__.items(): + if name[0] == '_': + continue + + if not func.__code__: + continue + + params = inspect.signature(func).parameters + params = [str(info) for name, info in params.items()] + params = ', '.join(params[1:]) + + command_sig = '\t' + name + + if params: + command_sig += ': '+params + + if func.__doc__: + command_sig += '\n'+'\n'.join( + ['\t\t'+line.strip() for line in func.__doc__.splitlines()])+'\n' + + helplines.append(command_sig) + + helplines.append('\t'+'quit') + + helplines.append("\n") + helplines.append("Source-Names:") + for source in self.sources: + helplines.append("\t"+source) + + helplines.append("\n") + helplines.append("Stream-Blanker Sources-Names:") + for source in self.blankerSources: + helplines.append("\t"+source) + + helplines.append("\n") + helplines.append("Composition-Modes:") + for mode in CompositeModes: + helplines.append("\t"+mode.name) + + return OkResponse("\n".join(helplines)) def _get_video_status(self): a = encodeName( self.sources, self.pipeline.vmix.getVideoSourceA() ) |