Initial leyk remote client
This commit is contained in:
parent
374f09a88a
commit
933e90e189
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,7 @@
|
|||||||
|
config.py
|
||||||
|
*.warn
|
||||||
|
*.log
|
||||||
|
|
||||||
# ---> Python
|
# ---> Python
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
18
.gitmodules
vendored
Normal file
18
.gitmodules
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[submodule "protocol"]
|
||||||
|
path = protocol
|
||||||
|
url = https://git.mount-mockery.de/application/leyk_protocol
|
||||||
|
[submodule "report"]
|
||||||
|
path = report
|
||||||
|
url = https://git.mount-mockery.de/pylib/report.git
|
||||||
|
[submodule "socket_protocol"]
|
||||||
|
path = socket_protocol
|
||||||
|
url = https://git.mount-mockery.de/pylib/socket_protocol.git
|
||||||
|
[submodule "stringtools"]
|
||||||
|
path = stringtools
|
||||||
|
url = https://git.mount-mockery.de/pylib/stringtools.git
|
||||||
|
[submodule "task"]
|
||||||
|
path = task
|
||||||
|
url = https://git.mount-mockery.de/pylib/task.git
|
||||||
|
[submodule "tcp_socket"]
|
||||||
|
path = tcp_socket
|
||||||
|
url = https://git.mount-mockery.de/pylib/tcp_socket.git
|
17
.project
Normal file
17
.project
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>leyk</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.python.pydev.PyDevBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.python.pydev.pythonNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
8
.pydevproject
Normal file
8
.pydevproject
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||||
|
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||||
|
<path>/${PROJECT_DIR_NAME}</path>
|
||||||
|
</pydev_pathproperty>
|
||||||
|
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
||||||
|
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||||
|
</pydev_project>
|
1
protocol
Submodule
1
protocol
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 6ac1b584fb53aeb58c1b9809fff306a56dd32400
|
1
report
Submodule
1
report
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 98fea3a4d45ba906d08a8ebc90525fb3592f06be
|
1
socket_protocol
Submodule
1
socket_protocol
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 127ef51719f2fdbc6699f7e0751f9d92f6773f0f
|
1
stringtools
Submodule
1
stringtools
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit b86248c1a3a3456e489e007857271106e1ecf090
|
1
task
Submodule
1
task
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit d3fbc5934051ab165723ca37e8f02596329f174a
|
66
tcp_client.py
Normal file
66
tcp_client.py
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
|
||||||
|
import config
|
||||||
|
import os
|
||||||
|
import protocol
|
||||||
|
import report
|
||||||
|
import sys
|
||||||
|
import tcp_socket
|
||||||
|
|
||||||
|
|
||||||
|
def help_msg():
|
||||||
|
print(""""Possible commands are:
|
||||||
|
* q[uit]
|
||||||
|
* auto[matic]
|
||||||
|
* man[ual]
|
||||||
|
* mode
|
||||||
|
* state
|
||||||
|
* get [all,bakehose,bakery,mill,reesehouse,ploenlein]
|
||||||
|
* set [all,bakehose,bakery,mill,reesehouse,ploenlein] [on,off]""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
report.appLoggingConfigure(os.path.dirname(__file__), 'logfile', config.loggers)
|
||||||
|
c = tcp_socket.tcp_client_stp(config.server_ip, config.server_port)
|
||||||
|
prot = protocol.my_client_protocol(c, secret=config.secret)
|
||||||
|
target_dict = {
|
||||||
|
'bakehouse': [prot.DID_BAKE_HOUSE, ],
|
||||||
|
'bakery': [prot.DID_BAKERY, ],
|
||||||
|
'mill': [prot.DID_MILL, ],
|
||||||
|
'ploenlein': [prot.DID_PLOENLEIN, ],
|
||||||
|
'reesehouse': [prot.DID_REESE_HOUSE, ],
|
||||||
|
'all': [prot.DID_BAKE_HOUSE, prot.DID_BAKERY, prot.DID_MILL, prot.DID_PLOENLEIN, prot.DID_REESE_HOUSE]
|
||||||
|
}
|
||||||
|
if prot.authentificate():
|
||||||
|
help_msg()
|
||||||
|
cmd = None
|
||||||
|
while cmd not in ["q", "quit"]:
|
||||||
|
cmd = sys.stdin.readline()
|
||||||
|
cmd = cmd.lower().strip('\n')
|
||||||
|
if cmd == 'help':
|
||||||
|
help_msg()
|
||||||
|
elif cmd in ["auto", "automatic"]:
|
||||||
|
prot.send(prot.SID_EXECUTE_REQUEST, prot.DID_MODE, 'automatic')
|
||||||
|
elif cmd in ["man", "manual"]:
|
||||||
|
prot.send(prot.SID_EXECUTE_REQUEST, prot.DID_MODE, 'manual')
|
||||||
|
elif cmd == "mode":
|
||||||
|
prot.send(prot.SID_READ_REQUEST, prot.DID_MODE, None)
|
||||||
|
elif cmd == "state":
|
||||||
|
prot.send(prot.SID_READ_REQUEST, prot.DID_STATE, None)
|
||||||
|
elif cmd.startswith('get '):
|
||||||
|
target = target_dict.get(cmd.split(' ')[1])
|
||||||
|
if target is not None:
|
||||||
|
for t in target:
|
||||||
|
prot.send(prot.SID_READ_REQUEST, t, None)
|
||||||
|
elif cmd.startswith('set '):
|
||||||
|
target = target_dict.get(cmd.split(' ')[1])
|
||||||
|
try:
|
||||||
|
state = {'on': True, 'off': False}.get(cmd.split(' ')[2])
|
||||||
|
except IndexError:
|
||||||
|
state = None
|
||||||
|
if target is not None and state is not None:
|
||||||
|
for t in target:
|
||||||
|
prot.send(prot.SID_EXECUTE_REQUEST, t, state)
|
||||||
|
c.close()
|
1
tcp_socket
Submodule
1
tcp_socket
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 62f13e2d878b09b81d094c2f77dbd830d72be2c7
|
Loading…
x
Reference in New Issue
Block a user