forked from maoterodapena/pysouliss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (32 loc) · 1.12 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Example for using pysouliss.
"""
import souliss.pysouliss as souliss
from optparse import OptionParser
import logging
_LOGGER = logging.getLogger(__name__)
def set_main_options():
usage = "usage: %prog [options]"
parser = OptionParser(usage)
parser.add_option("-g", "--gateway", dest="gateway",
help="Souliss gateway host or IP")
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose")
(options, args) = parser.parse_args()
if options.gateway is None:
parser.error("You need to provide a gateway host or IP")
if options.verbose:
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.DEBUG)
else:
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO)
return options
if __name__ == "__main__":
# Parse command line options
options = set_main_options()
# Try to connect to souliss gateway
SOULISS = souliss.Souliss(options.gateway)
SOULISS.database_structure_request()
while True:
SOULISS.get_response()
else:
print("Terminated")