indipyclient 0.6.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- indipyclient/__init__.py +9 -0
- indipyclient/__main__.py +126 -0
- indipyclient/console/__init__.py +1 -0
- indipyclient/console/choosevectorscreen.py +1316 -0
- indipyclient/console/consoleclient.py +369 -0
- indipyclient/console/devicesscreen.py +546 -0
- indipyclient/console/memberscreen.py +182 -0
- indipyclient/console/vectorscreen.py +1492 -0
- indipyclient/console/widgets.py +1434 -0
- indipyclient/console/windows.py +636 -0
- indipyclient/events.py +681 -0
- indipyclient/ipyclient.py +1221 -0
- indipyclient/propertymembers.py +530 -0
- indipyclient/propertyvectors.py +888 -0
- indipyclient/queclient.py +205 -0
- indipyclient-0.6.9.dist-info/LICENSE +21 -0
- indipyclient-0.6.9.dist-info/METADATA +91 -0
- indipyclient-0.6.9.dist-info/RECORD +20 -0
- indipyclient-0.6.9.dist-info/WHEEL +4 -0
- indipyclient-0.6.9.dist-info/entry_points.txt +3 -0
indipyclient/__init__.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
from .ipyclient import IPyClient
|
|
4
|
+
from .events import (delProperty, defSwitchVector, defTextVector, defNumberVector, defLightVector, defBLOBVector,
|
|
5
|
+
setSwitchVector, setTextVector, setNumberVector, setLightVector, setBLOBVector, Message, VectorTimeOut)
|
|
6
|
+
|
|
7
|
+
from .propertymembers import getfloat
|
|
8
|
+
|
|
9
|
+
version = "0.6.9"
|
indipyclient/__main__.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
|
|
2
|
+
"""Creates a terminal client
|
|
3
|
+
|
|
4
|
+
Try
|
|
5
|
+
|
|
6
|
+
python3 -m indipyclient --help
|
|
7
|
+
|
|
8
|
+
For a description of options
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
import sys, argparse, asyncio, pathlib, logging
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger()
|
|
15
|
+
|
|
16
|
+
# logger is the root logger, with level and handler set here
|
|
17
|
+
# by the arguments given. If no logging option is given, it
|
|
18
|
+
# has a NullHandler() added
|
|
19
|
+
|
|
20
|
+
from . import version
|
|
21
|
+
|
|
22
|
+
from .console import ConsoleClient
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def setlogging(client, level, logfile):
|
|
26
|
+
"""Sets the logging level and logfile, returns the level on success, None on failure.
|
|
27
|
+
level should be an integer, one of 1, 2, 3 or 4."""
|
|
28
|
+
|
|
29
|
+
# loglevel:1 Information and error messages only
|
|
30
|
+
# loglevel:2 log vector tags without members or contents
|
|
31
|
+
# loglevel:3 log vectors and members - but not BLOB contents
|
|
32
|
+
# loglevel:4 log vectors and all contents
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
if not level in (1, 2, 3, 4):
|
|
36
|
+
return
|
|
37
|
+
logfile = pathlib.Path(logfile).expanduser().resolve()
|
|
38
|
+
|
|
39
|
+
if level == 4:
|
|
40
|
+
logger.setLevel(logging.DEBUG)
|
|
41
|
+
client.debug_verbosity(3)
|
|
42
|
+
elif level == 3:
|
|
43
|
+
logger.setLevel(logging.DEBUG)
|
|
44
|
+
client.debug_verbosity(2)
|
|
45
|
+
elif level == 2:
|
|
46
|
+
logger.setLevel(logging.DEBUG)
|
|
47
|
+
client.debug_verbosity(1)
|
|
48
|
+
elif level == 1:
|
|
49
|
+
logger.setLevel(logging.INFO)
|
|
50
|
+
client.debug_verbosity(0)
|
|
51
|
+
# If logging debug not enabled, reduce traceback info
|
|
52
|
+
sys.tracebacklimit = 0
|
|
53
|
+
|
|
54
|
+
fh = logging.FileHandler(logfile)
|
|
55
|
+
logger.addHandler(fh)
|
|
56
|
+
except Exception:
|
|
57
|
+
return
|
|
58
|
+
return level
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def main():
|
|
62
|
+
"""The commandline entry point to run the terminal client."""
|
|
63
|
+
|
|
64
|
+
parser = argparse.ArgumentParser(usage="indipyclient [options]",
|
|
65
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
66
|
+
description="Terminal client to communicate to an INDI service.",
|
|
67
|
+
epilog="""The BLOB's folder can also be set from within the session.
|
|
68
|
+
Setting loglevel and logfile should only be used for brief
|
|
69
|
+
diagnostic purposes, the logfile could grow very big.
|
|
70
|
+
loglevel:1 Information and error messages only, no exception trace.
|
|
71
|
+
The following levels enable exception traces in the logs
|
|
72
|
+
loglevel:2 As 1 plus xml vector tags without members or contents,
|
|
73
|
+
loglevel:3 As 1 plus xml vectors and members - but not BLOB contents,
|
|
74
|
+
loglevel:4 As 1 plus xml vectors and all contents
|
|
75
|
+
""")
|
|
76
|
+
parser.add_argument("-p", "--port", type=int, default=7624, help="Port of the INDI server (default 7624).")
|
|
77
|
+
parser.add_argument("--host", default="localhost", help="Hostname/IP of the INDI server (default localhost).")
|
|
78
|
+
parser.add_argument("-b", "--blobs", help="Optional folder where BLOB's will be saved.")
|
|
79
|
+
parser.add_argument("--loglevel", help="Enables logging, value 1, 2, 3 or 4.")
|
|
80
|
+
parser.add_argument("--logfile", help="File where logs will be saved")
|
|
81
|
+
|
|
82
|
+
parser.add_argument("--version", action="version", version=version)
|
|
83
|
+
args = parser.parse_args()
|
|
84
|
+
|
|
85
|
+
if args.blobs:
|
|
86
|
+
try:
|
|
87
|
+
blobfolder = pathlib.Path(args.blobs).expanduser().resolve()
|
|
88
|
+
except Exception:
|
|
89
|
+
print("Error: If given, the BLOB's folder should be an existing directory")
|
|
90
|
+
return 1
|
|
91
|
+
else:
|
|
92
|
+
if not blobfolder.is_dir():
|
|
93
|
+
print("Error: If given, the BLOB's folder should be an existing directory")
|
|
94
|
+
return 1
|
|
95
|
+
else:
|
|
96
|
+
blobfolder = None
|
|
97
|
+
|
|
98
|
+
if args.loglevel:
|
|
99
|
+
if args.loglevel not in ("1", "2", "3", "4"):
|
|
100
|
+
print("Error: If given, the loglevel should be 1, 2, 3 or 4")
|
|
101
|
+
return 1
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
client = ConsoleClient(indihost=args.host, indiport=args.port, blobfolder=blobfolder)
|
|
105
|
+
|
|
106
|
+
if args.loglevel and args.logfile:
|
|
107
|
+
loglevel = int(args.loglevel)
|
|
108
|
+
level = setlogging(client, loglevel, args.logfile)
|
|
109
|
+
if level != loglevel:
|
|
110
|
+
print("Error: Failed to set logging")
|
|
111
|
+
return 1
|
|
112
|
+
else:
|
|
113
|
+
logger.addHandler(logging.NullHandler())
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
# Starts the client, creates the console screens
|
|
117
|
+
asyncio.run(client.asyncrun())
|
|
118
|
+
finally:
|
|
119
|
+
# clear curses setup
|
|
120
|
+
client.console_reset()
|
|
121
|
+
|
|
122
|
+
return 0
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
if __name__ == "__main__":
|
|
126
|
+
sys.exit(main())
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .consoleclient import ConsoleClient
|