aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst1
-rw-r--r--mypy.ini3
-rw-r--r--pyapd/ctl_client.py14
-rwxr-xr-xpyapdctl25
4 files changed, 35 insertions, 8 deletions
diff --git a/README.rst b/README.rst
index ceaf2a5..c9d3913 100644
--- a/README.rst
+++ b/README.rst
@@ -21,7 +21,6 @@ explicitely.
* `Python3 <https://www.python.org/>` >= 3.7
* `Tornado <https://www.tornadoweb.org>`_
* `ruamel.yaml <https://bitbucket.org/ruamel/yaml>`_ >= 0.15
-* `guacamole <https://github.com/zyga/guacamole/>`
License
=======
diff --git a/mypy.ini b/mypy.ini
index 2db00c6..4447f48 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -5,6 +5,3 @@ ignore_missing_imports = True
[mypy-tornado.*]
ignore_missing_imports = True
-
-[mypy-guacamole.*]
-ignore_missing_imports = True
diff --git a/pyapd/ctl_client.py b/pyapd/ctl_client.py
index 8c692f9..d788623 100644
--- a/pyapd/ctl_client.py
+++ b/pyapd/ctl_client.py
@@ -1,23 +1,29 @@
import json
import socket
-import guacamole
+class ClientCommand():
+ help = ''
+
+ def register_arguments(self, parser):
+ pass
-class ClientCommand(guacamole.Command):
def send_command(self, cmd):
print("Sending command", cmd)
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect(self.config.ctl_socket)
s.send(json.dumps(cmd).encode())
+ def invoked(self):
+ pass
+
class Ping(ClientCommand):
def get_command(self):
return {"command": "ping"}
- def invoked(self, ctx):
- print(self.get_command)
+ def invoked(self):
+ print(self.get_command())
class AddObject(ClientCommand):
diff --git a/pyapdctl b/pyapdctl
new file mode 100755
index 0000000..ead5085
--- /dev/null
+++ b/pyapdctl
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+
+import argparse
+
+from pyapd import ctl_client, config
+
+
+class Client():
+ sub_commands = (
+ ('ping', ctl_client.Ping()),
+ ('add_object', ctl_client.AddObject()),
+ )
+
+ def main(self):
+ self.parser = argparse.ArgumentParser()
+ self.subparsers = self.parser.add_subparsers()
+ for name, sub in self.sub_commands:
+ s_parser = self.subparsers.add_parser(name, help=sub.help)
+ sub.register_arguments(s_parser)
+ s_parser.set_defaults(func=sub.invoked)
+ self.args = self.parser.parse_args()
+ self.args.func(self.args)
+
+if __name__ == "__main__":
+ Client().main()