瀏覽代碼

2nd Module update

master
Dirk Alders 4 年之前
父節點
當前提交
cd5f156076
共有 4 個檔案被更改,包括 17 行新增16 行删除
  1. 1
    1
      protocol
  2. 1
    1
      socket_protocol
  3. 1
    1
      stringtools
  4. 14
    13
      tcp_client.py

+ 1
- 1
protocol

1
-Subproject commit 70c458d34951cfbf1bddcf4a35fe7112797b106b
1
+Subproject commit 551e3e558dd54933e10b4e4806ee3f8c02dbfe19

+ 1
- 1
socket_protocol

1
-Subproject commit b1a3f75e6135929acab149028df3d4bbe7fdb28c
1
+Subproject commit 35d9f688a4f080a8cae70a18e27036b55399edde

+ 1
- 1
stringtools

1
-Subproject commit 76d8ae9b1bfd894bc5f4b830394ce0552120a508
1
+Subproject commit 5ac92e2b864cd27bd4026352ba9149f4d23ca019

+ 14
- 13
tcp_client.py 查看文件

5
 import os
5
 import os
6
 import protocol
6
 import protocol
7
 import report
7
 import report
8
+import socket_protocol
8
 import sys
9
 import sys
9
 import tcp_socket
10
 import tcp_socket
10
 
11
 
22
 
23
 
23
 
24
 
24
 if __name__ == '__main__':
25
 if __name__ == '__main__':
25
-    report.appLoggingConfigure(os.path.dirname(__file__), config.LOGTARGET, ((config.APP_NAME, 'DEBUG'), ), fmt=config.formatter, host=config.LOGHOST, port=config.LOGPORT)
26
+    report.appLoggingConfigure(os.path.dirname(__file__), config.LOGTARGET, ((config.APP_NAME, config.LOGLVL), ), fmt=config.formatter, host=config.LOGHOST, port=config.LOGPORT)
26
     c = tcp_socket.tcp_client_stp(config.server_ip, config.server_port)
27
     c = tcp_socket.tcp_client_stp(config.server_ip, config.server_port)
27
     prot = protocol.my_client_protocol(c, secret=config.secret, channel_name='leyk')
28
     prot = protocol.my_client_protocol(c, secret=config.secret, channel_name='leyk')
28
     target_dict = {
29
     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]
30
+        'bakehouse': [protocol.DID_BAKE_HOUSE, ],
31
+        'bakery': [protocol.DID_BAKERY, ],
32
+        'mill': [protocol.DID_MILL, ],
33
+        'ploenlein': [protocol.DID_PLOENLEIN, ],
34
+        'reesehouse': [protocol.DID_REESE_HOUSE, ],
35
+        'all': [protocol.DID_BAKE_HOUSE, protocol.DID_BAKERY, protocol.DID_MILL, protocol.DID_PLOENLEIN, protocol.DID_REESE_HOUSE]
35
     }
36
     }
36
     if prot.authentificate():
37
     if prot.authentificate():
37
         help_msg()
38
         help_msg()
42
             if cmd == 'help':
43
             if cmd == 'help':
43
                 help_msg()
44
                 help_msg()
44
             elif cmd in ["auto", "automatic"]:
45
             elif cmd in ["auto", "automatic"]:
45
-                prot.send(prot.SID_EXECUTE_REQUEST, prot.DID_MODE, 'automatic')
46
+                prot.send(socket_protocol.SID_EXECUTE_REQUEST, protocol.DID_MODE, 'automatic')
46
             elif cmd in ["man", "manual"]:
47
             elif cmd in ["man", "manual"]:
47
-                prot.send(prot.SID_EXECUTE_REQUEST, prot.DID_MODE, 'manual')
48
+                prot.send(socket_protocol.SID_EXECUTE_REQUEST, protocol.DID_MODE, 'manual')
48
             elif cmd == "mode":
49
             elif cmd == "mode":
49
-                prot.send(prot.SID_READ_REQUEST, prot.DID_MODE, None)
50
+                prot.send(socket_protocol.SID_READ_REQUEST, protocol.DID_MODE, None)
50
             elif cmd == "state":
51
             elif cmd == "state":
51
-                prot.send(prot.SID_READ_REQUEST, prot.DID_STATE, None)
52
+                prot.send(socket_protocol.SID_READ_REQUEST, protocol.DID_STATE, None)
52
             elif cmd.startswith('get '):
53
             elif cmd.startswith('get '):
53
                 target = target_dict.get(cmd.split(' ')[1])
54
                 target = target_dict.get(cmd.split(' ')[1])
54
                 if target is not None:
55
                 if target is not None:
55
                     for t in target:
56
                     for t in target:
56
-                        prot.send(prot.SID_READ_REQUEST, t, None)
57
+                        prot.send(socket_protocol.SID_READ_REQUEST, t, None)
57
             elif cmd.startswith('set '):
58
             elif cmd.startswith('set '):
58
                 target = target_dict.get(cmd.split(' ')[1])
59
                 target = target_dict.get(cmd.split(' ')[1])
59
                 try:
60
                 try:
62
                     state = None
63
                     state = None
63
                 if target is not None and state is not None:
64
                 if target is not None and state is not None:
64
                     for t in target:
65
                     for t in target:
65
-                        prot.send(prot.SID_EXECUTE_REQUEST, t, state)
66
+                        prot.send(socket_protocol.SID_EXECUTE_REQUEST, t, state)
66
     c.close()
67
     c.close()

Loading…
取消
儲存