Преглед на файлове

Initial leyk remote client

master
Dirk Alders преди 4 години
родител
ревизия
933e90e189
променени са 11 файла, в които са добавени 119 реда и са изтрити 0 реда
  1. 4
    0
      .gitignore
  2. 18
    0
      .gitmodules
  3. 17
    0
      .project
  4. 8
    0
      .pydevproject
  5. 1
    0
      protocol
  6. 1
    0
      report
  7. 1
    0
      socket_protocol
  8. 1
    0
      stringtools
  9. 1
    0
      task
  10. 66
    0
      tcp_client.py
  11. 1
    0
      tcp_socket

+ 4
- 0
.gitignore Целия файл

@@ -1,3 +1,7 @@
1
+config.py
2
+*.warn
3
+*.log
4
+
1 5
 # ---> Python
2 6
 # Byte-compiled / optimized / DLL files
3 7
 __pycache__/

+ 18
- 0
.gitmodules Целия файл

@@ -0,0 +1,18 @@
1
+[submodule "protocol"]
2
+	path = protocol
3
+	url = https://git.mount-mockery.de/application/leyk_protocol
4
+[submodule "report"]
5
+	path = report
6
+	url = https://git.mount-mockery.de/pylib/report.git
7
+[submodule "socket_protocol"]
8
+	path = socket_protocol
9
+	url = https://git.mount-mockery.de/pylib/socket_protocol.git
10
+[submodule "stringtools"]
11
+	path = stringtools
12
+	url = https://git.mount-mockery.de/pylib/stringtools.git
13
+[submodule "task"]
14
+	path = task
15
+	url = https://git.mount-mockery.de/pylib/task.git
16
+[submodule "tcp_socket"]
17
+	path = tcp_socket
18
+	url = https://git.mount-mockery.de/pylib/tcp_socket.git

+ 17
- 0
.project Целия файл

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>leyk</name>
4
+	<comment></comment>
5
+	<projects>
6
+	</projects>
7
+	<buildSpec>
8
+		<buildCommand>
9
+			<name>org.python.pydev.PyDevBuilder</name>
10
+			<arguments>
11
+			</arguments>
12
+		</buildCommand>
13
+	</buildSpec>
14
+	<natures>
15
+		<nature>org.python.pydev.pythonNature</nature>
16
+	</natures>
17
+</projectDescription>

+ 8
- 0
.pydevproject Целия файл

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+<?eclipse-pydev version="1.0"?><pydev_project>
3
+    <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
4
+        <path>/${PROJECT_DIR_NAME}</path>
5
+    </pydev_pathproperty>
6
+    <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
7
+    <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
8
+</pydev_project>

+ 1
- 0
protocol

@@ -0,0 +1 @@
1
+Subproject commit 6ac1b584fb53aeb58c1b9809fff306a56dd32400

+ 1
- 0
report

@@ -0,0 +1 @@
1
+Subproject commit 98fea3a4d45ba906d08a8ebc90525fb3592f06be

+ 1
- 0
socket_protocol

@@ -0,0 +1 @@
1
+Subproject commit 127ef51719f2fdbc6699f7e0751f9d92f6773f0f

+ 1
- 0
stringtools

@@ -0,0 +1 @@
1
+Subproject commit b86248c1a3a3456e489e007857271106e1ecf090

+ 1
- 0
task

@@ -0,0 +1 @@
1
+Subproject commit d3fbc5934051ab165723ca37e8f02596329f174a

+ 66
- 0
tcp_client.py Целия файл

@@ -0,0 +1,66 @@
1
+#!/usr/bin/env python
2
+# -*- coding: UTF-8 -*-
3
+
4
+import config
5
+import os
6
+import protocol
7
+import report
8
+import sys
9
+import tcp_socket
10
+
11
+
12
+def help_msg():
13
+    print(""""Possible commands are: 
14
+ * q[uit]
15
+ * auto[matic]
16
+ * man[ual]
17
+ * mode
18
+ * state
19
+ * get [all,bakehose,bakery,mill,reesehouse,ploenlein]
20
+ * set [all,bakehose,bakery,mill,reesehouse,ploenlein] [on,off]""")
21
+
22
+
23
+
24
+if __name__ == '__main__':
25
+    report.appLoggingConfigure(os.path.dirname(__file__), 'logfile', config.loggers)
26
+    c = tcp_socket.tcp_client_stp(config.server_ip, config.server_port)
27
+    prot = protocol.my_client_protocol(c, secret=config.secret)
28
+    target_dict = {
29
+        'bakehouse': [prot.DID_BAKE_HOUSE, ],
30
+        'bakery': [prot.DID_BAKERY, ],
31
+        'mill': [prot.DID_MILL, ],
32
+        'ploenlein': [prot.DID_PLOENLEIN, ],
33
+        'reesehouse': [prot.DID_REESE_HOUSE, ],
34
+        'all': [prot.DID_BAKE_HOUSE, prot.DID_BAKERY, prot.DID_MILL, prot.DID_PLOENLEIN, prot.DID_REESE_HOUSE]
35
+    }
36
+    if prot.authentificate():
37
+        help_msg()
38
+        cmd = None
39
+        while cmd not in ["q", "quit"]:
40
+            cmd = sys.stdin.readline()
41
+            cmd = cmd.lower().strip('\n')
42
+            if cmd == 'help':
43
+                help_msg()
44
+            elif cmd in ["auto", "automatic"]:
45
+                prot.send(prot.SID_EXECUTE_REQUEST, prot.DID_MODE, 'automatic')
46
+            elif cmd in ["man", "manual"]:
47
+                prot.send(prot.SID_EXECUTE_REQUEST, prot.DID_MODE, 'manual')
48
+            elif cmd == "mode":
49
+                prot.send(prot.SID_READ_REQUEST, prot.DID_MODE, None)
50
+            elif cmd == "state":
51
+                prot.send(prot.SID_READ_REQUEST, prot.DID_STATE, None)
52
+            elif cmd.startswith('get '):
53
+                target = target_dict.get(cmd.split(' ')[1])
54
+                if target is not None:
55
+                    for t in target:
56
+                        prot.send(prot.SID_READ_REQUEST, t, None)
57
+            elif cmd.startswith('set '):
58
+                target = target_dict.get(cmd.split(' ')[1])
59
+                try:
60
+                    state = {'on': True, 'off': False}.get(cmd.split(' ')[2])
61
+                except IndexError:
62
+                    state = None
63
+                if target is not None and state is not None:
64
+                    for t in target:
65
+                        prot.send(prot.SID_EXECUTE_REQUEST, t, state)
66
+    c.close()

+ 1
- 0
tcp_socket

@@ -0,0 +1 @@
1
+Subproject commit 62f13e2d878b09b81d094c2f77dbd830d72be2c7

Loading…
Отказ
Запис